GitHub Action Manage Stale PRs - SSWConsulting/SSW.Rules.Content GitHub Wiki
This GitHub Action helps manage the lifecycle of pull requests by automatically labeling PRs based on age and flagging those that may be suffering from merge debt. Itโs part of SSWโs standard pull request workflow.
When It Runs
- On PR opened or marked โready for reviewโ, if it's targeting the
mainbranch - Every 2 hours
- Manually, using the "Run workflow" button in GitHub
What It Does
On PR Creation (pull_request)
-
When a new PR is opened or marked ready:
-
Checks if it's not cross-repository
-
Applies the label:
Age: ๐ฅ - New(i.e. "about 2 hours old")
-
This gives the PR an initial "age" label as a starting point.
๐ On Schedule (cron)
Every 2 hours, the workflow will:
-
Ensure labels exist for the following age groups:
-
๐ฅ New โ 2 hours
-
๐ฃ Young โ 4 hours
-
๐ฅ Adolescent โ 8 hours
-
๐ค Mature โ 16 hours
-
๐ Old โ 32 hours
-
๐ Ancient โ 64 hours
-
๐ฆ Extinct โ 128+ hours
-
-
Loop through all open PRs
-
Calculates how many hours old each PR is
-
Applies the appropriate age label
-
Removes any other age labels
-
-
Add โMerge Debtโ label & comment if needed
-
If a PR is over 36 hours old
-
And the author is not a bot
-
And it doesnโt already have a "๐ฅ Merge Debt" label
โ Then it:-
Adds the ๐ฅ Merge Debt label
-
Posts a friendly comment reminding the author to take action:
"This PR has been here a while... Please action (e.g. get a review) and merge or close."
-
-