docs/branch-lifecycle-policy.md
This repository enforces a branch lifecycle policy to keep the branch list clean and manageable. Stale branches are identified automatically and removed after a period of inactivity.
A scheduled GitHub Action (cleanup-stale-branches.yml) runs every Monday at 08:00 UTC and scans all remote branches for inactivity.
| Branch type | Stale after | Examples |
|---|---|---|
copilot/* | 90 days | copilot/fix-xyz, copilot/workspace |
| All other branches | 180 days | user/feature, abhi/experiment |
Scheduled runs are always dry run (report only). Deletions require a manual trigger.
The following branch patterns are always excluded from cleanup, regardless of age:
main / masterdeveloprelease/*hotfix/*archive/**-stable (e.g., 0.72-stable, 0.80-stable)preview-* (e.g., preview-0.80-test)If your branch must be retained beyond the staleness threshold, use any of these methods:
Rename your branch under archive/:
git branch -m my-old-branch archive/my-old-branch
git push origin archive/my-old-branch
git push origin --delete my-old-branch
Create or keep a pull request (even a draft) from your branch. The workflow skips any branch with an open PR.
Add your branch prefix to the PROTECTED regex in the workflow file and submit a PR.
Maintainers can trigger the workflow manually from the Actions tab:
dry_run = false to actually delete stale branchesQ: What happens if my branch is deleted by mistake? A: Git branch deletions on GitHub are reversible for a short period. You can also restore from a local clone.
Q: Will this delete branches with open pull requests? A: No. The workflow checks for open PRs (including drafts) and skips those branches.
Q: What about stable and preview branches?
A: All *-stable and preview-* branches are protected by default and will never be deleted.