[GitHub Actions] Close stale draft pull requests#3799
Conversation
ec1560b to
f8b51bf
Compare
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds automation to warn and close stale draft pull requests so abandoned drafts don’t accumulate indefinitely.
Changes:
- Introduces a scheduled + manually-triggerable GitHub Actions workflow to evaluate activity on open draft PRs.
- Posts a warning after 30 idle days, then closes after a 7-day grace period if no new activity occurs.
- Generates an Actions job summary and optionally posts a Slack report.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@mho22 I took the liberty to add reporting so that we can get notified about the stale PRs being closed via Slack via a It also adds a final Actions output so that the list of affected PRs can be reviewed there. What do you think? We can also revert this if you think it's not a good idea. |
|
@akirk I really like the idea! I am only worried about the amount of "reminders" we will get on slack over time and being overwhelmed to the point to not read them anymore. But that needs to be tested. And if it doesn't work as planned we can reset that with a new pull request. |
Motivation for the change, related issues
Open draft pull requests in this repository accumulate indefinitely. There are 56 open drafts today, and 33 of them have had no commits, comments, or reviews for more than 30 days — several have been silent for over six months. There is no automation that surfaces or retires abandoned drafts, so they bury PRs that are still active.
Implementation details
Adds
.github/workflows/stale-draft-pull-requests.yml, a scheduled workflow that runs daily at 07:00 UTC and can also be triggered manually from the Actions tab. For each open draft pull request, the workflow computes the last real activity timestamp from:The bot's own warning comments are excluded from this activity calculation so they don't reset the idle clock.
For each draft the workflow does one of:
Pushing a commit, leaving a comment, or submitting a review after a warning invalidates the active warning and restarts the cycle, so a draft is never closed without a 7-day grace window after a warning is posted.
Other workflow hygiene:
concurrency.group: stale-draft-prsprevents overlapping runs from posting duplicate warnings.if: github.repository == 'WordPress/wordpress-playground'keeps forks from running the workflow against their own drafts.permissions: {}denies all scopes; the job opts in only topull-requests: writeandissues: write.actions/github-scriptis pinned to the commit SHA forv7.0.1since the job has write permissions.Testing Instructions (or ideally a Blueprint)
GitHub Actions workflows are difficult to unit-test in isolation. After merging:
workflow_dispatch) and confirm it iterates every open draft pull request without errors.