From 7c306e67010545128dbe1e28e6a6eaca7bec32ee Mon Sep 17 00:00:00 2001 From: Putta Khunchalee Date: Sun, 25 Feb 2024 01:14:32 +0700 Subject: [PATCH] Fixes PR updated_at comparison on Housekeep Actions (#690) --- .github/workflows/main.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index eb6cd4a75..a444609bc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -22,15 +22,20 @@ jobs: run: pip install PyGithub - name: Update PRs run: | - from datetime import datetime + from datetime import datetime, timezone from github import Auth, Github - now = datetime.now() + now = datetime.now(timezone.utc) gh = Github(auth=Auth.Token("${{ secrets.GITHUB_TOKEN }}")) repo = gh.get_repo("${{ github.repository }}") for pull in repo.get_pulls("open", "updated", "desc", "${{ github.ref_name }}"): if (now - pull.updated_at).days > 30: break - pull.add_to_labels("B-out-of-date") + ood = False + for label in pull.labels: + if label.name == "B-out-of-date": + ood = True + if not ood: + pull.add_to_labels("B-out-of-date") shell: python