Skip to content

Comments

Add stale branch cleanup workflow and lifecycle policy#15680

Open
HariniMalothu17 wants to merge 4 commits intomicrosoft:mainfrom
HariniMalothu17:main
Open

Add stale branch cleanup workflow and lifecycle policy#15680
HariniMalothu17 wants to merge 4 commits intomicrosoft:mainfrom
HariniMalothu17:main

Conversation

@HariniMalothu17
Copy link
Contributor

@HariniMalothu17 HariniMalothu17 commented Feb 20, 2026

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

  • Automation (AI changes or Github Actions to reduce effort of manual tasks)

Resolves #15034

Microsoft Reviewers: Open in CodeFlow

@HariniMalothu17 HariniMalothu17 requested review from a team as code owners February 20, 2026 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

To Implement Repository Branch Lifecycle Policy

1 participant