Add workflow to auto-close stale PRs after 60 days
Description
Implements automated cleanup of inactive PRs to address the backlog of 69+ open PRs, many stale for months or years.
Workflow behavior:
- Day 46: First warning comment +
stalelabel - Day 53: Final warning comment +
stale-final-warninglabel - Day 60: PR auto-closed with notification
- Updated PRs have stale labels automatically removed
Exemptions:
PRs labeled pinned, security, or dependencies are never auto-closed.
Schedule: Runs daily at 00:00 UTC via cron, manually triggerable via workflow_dispatch.
Implementation:
Uses actions/github-script@v7 for custom logic with full error handling and logging. Processes all open PRs via pagination.
Testing
No existing tests. Workflow syntax validated. Logic tested with mock data to verify correct behavior at each threshold (46/53/60 days).
Documentation
No documentation changes needed. Workflow is self-documenting via inline comments.
Original prompt
This section details on the original issue you should resolve
<issue_title>Stale PRs should be auto-closed</issue_title> <issue_description>### Describe the feature you'd like supported
We have 69 active PRs into MsQuic, and many of them haven't been updated for months or years. We should clean those up and stay clean.
Proposed solution
Add a periodic action that scans for PRs not modified within 60 days and closes those PRs. The PR author should be notified 2 weeks and 1 week before it gets closed.
Additional context
No response</issue_description>
Comments on the Issue (you are @copilot in this section)
- Fixes microsoft/msquic#5576
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
Codecov Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 84.99%. Comparing base (4e84609) to head (17698a2).
Additional details and impacted files
@@ Coverage Diff @@
## main #5577 +/- ##
==========================================
- Coverage 86.34% 84.99% -1.35%
==========================================
Files 60 60
Lines 18663 18663
==========================================
- Hits 16114 15863 -251
- Misses 2549 2800 +251
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
Will this immediately close all currently stale PRs? Or will it start the clock from when it first runs?
Will this immediately close all currently stale PRs? Or will it start the clock from when it first runs?
Yeah I also wondered about its first run vs periodically going forward. I think it might insta-close the current PRs, which are still old, and can still be reactivated if that were to occur and the author wants to bring it back.
Updated the script with a simplified logic (it gets annoying to track state otherwise):
- one warning after 46 days
- close after 60 days
- any activity (other than setting the label) will remove the stale label
Will this immediately close all currently stale PRs? Or will it start the clock from when it first runs?
The new script won't close all stale PRs immediately, but it will set the stale label immediately (starting the 2 weeks countdown)