From 710a6ea078ec0f98c20fac55c60bb35361f345ba Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 20 Apr 2026 17:05:47 -0700 Subject: [PATCH] Auto close stale Draft PRs --- .github/workflows/close_stale_draft_prs.yml | 26 +++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/close_stale_draft_prs.yml diff --git a/.github/workflows/close_stale_draft_prs.yml b/.github/workflows/close_stale_draft_prs.yml new file mode 100644 index 000000000..f5704686d --- /dev/null +++ b/.github/workflows/close_stale_draft_prs.yml @@ -0,0 +1,26 @@ +name: Close stale draft PRs + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" + +jobs: + close-stale-drafts: + runs-on: ubuntu-latest + if: github.repository == 'Sonarr/Sonarr' + permissions: + pull-requests: write + steps: + - name: Close draft PRs inactive for 90+ days + env: + GH_TOKEN: ${{ github.token }} + GH_REPO: ${{ github.repository }} + run: | + cutoff=$(date -u -d '90 days ago' +%Y-%m-%dT%H:%M:%SZ) + gh pr list --draft --state open --limit 1000 \ + --json number,updatedAt \ + --jq ".[] | select(.updatedAt < \"$cutoff\") | .number" \ + | while read -r pr; do + gh pr close "$pr" --comment ":wave: This draft pull request has been closed automatically because it has not had any activity in 90 days. If you are still working on this, please update it and let us know so we can reopen it." + done