From 5f2ee9848c210e62d5f8ac757fcb436fa13515bd Mon Sep 17 00:00:00 2001 From: Phi Date: Wed, 22 Jan 2025 13:19:14 +0100 Subject: [PATCH 1/2] ci: automate stale labeling for inactive draft PRs ci: automate stale labeling for inactive draft PRs --- .github/workflows/stale.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 6b601f52a56..70c5adb1907 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -1,8 +1,9 @@ -name: Close and mark stale issue +name: Mark and close stale items on: schedule: - cron: '0 12 * * *' + workflow_dispatch: permissions: contents: read @@ -28,5 +29,8 @@ jobs: days-before-issue-close: 3 days-before-pr-stale: 5 days-before-pr-close: 3 + draft-days-before-stale: 365 # Mark draft PRs as stale after 1 year + draft-days-before-close: 30 # Close stale draft PRs after 30 days remove-stale-when-updated: true enable-statistics: true + \ No newline at end of file From 95ea3b9cfd76d6011eb844e00ad232b20066fead Mon Sep 17 00:00:00 2001 From: Phi Date: Mon, 27 Jan 2025 17:22:39 +0100 Subject: [PATCH 2/2] ci: add labelling draft PRs Add labelling draft PRs --- .github/workflows/stale.yml | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 70c5adb1907..64455355e4c 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -29,8 +29,24 @@ jobs: days-before-issue-close: 3 days-before-pr-stale: 5 days-before-pr-close: 3 - draft-days-before-stale: 365 # Mark draft PRs as stale after 1 year - draft-days-before-close: 30 # Close stale draft PRs after 30 days remove-stale-when-updated: true enable-statistics: true - \ No newline at end of file + label-stale-draft-prs: + permissions: + pull-requests: write + runs-on: ubuntu-latest + steps: + - name: Mark stale draft PRs + env: + GH_TOKEN: ${{ github.token }} + run: | + # Calculate cutoff date for last update (365 days ago) + cutoff_date=$(date -d "365 days ago" +%Y-%m-%d) + prs=$(gh pr list --repo $GITHUB_REPOSITORY --state open \ + --json number,updatedAt,isDraft \ + --jq ".[] | select(.isDraft) | select(.updatedAt < \"$cutoff_date\") | .number") + + for pr in $prs; do + echo "Marking PR #$pr as stale" + gh pr edit $pr --add-label "kind/stale" + done \ No newline at end of file