Add stale branch cleanup workflow and lifecycle policy#15680
Open
HariniMalothu17 wants to merge 4 commits intomicrosoft:mainfrom
Open
Add stale branch cleanup workflow and lifecycle policy#15680HariniMalothu17 wants to merge 4 commits intomicrosoft:mainfrom
HariniMalothu17 wants to merge 4 commits intomicrosoft:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduces a GitHub Action to automatically clean up stale branches and a documentation page outlining the branch lifecycle policy.
Changes
cleanup-stale-branches.yml
Scheduled to run every Monday at 08:00 UTC — automatically deletes stale branches
Can also be triggered manually with a dry-run option for previewing
Two-tier staleness thresholds:
copilot/* branches: 90 days
All other branches: 180 days
Protected branches (never deleted):
main, master, develop
release/, hotfix/, archive/*
-stable (e.g., 0.72-stable, 0.80-stable)
preview- (e.g., preview-0.80-test)
Skips branches with open PRs (including drafts)
If you need to keep a branch from being deleted, Rename it under archive/
branch-lifecycle-policy.md
Documents the cleanup policy, thresholds, and protected patterns
Explains how to preserve a branch from cleanup
FAQ for common questions
Motivation
The repository has accumulated many stale branches over time. This workflow helps maintain a clean branch list by automatically removing inactive branches while protecting important ones (stable releases, previews, branches with open PRs).
Testing
Ran the workflow manually in dry-run mode — completed successfully in 20s
Verified protected branch patterns against existing repo branches
Type of Change
Resolves #15034
Microsoft Reviewers: Open in CodeFlow