Implement automated monthly branch cleanup policy and announcement system #21299
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.
Overview
This PR implements a comprehensive automated branch cleanup system to maintain repository health, security, and performance by removing branches older than 24 months on a monthly basis.
Background
Based on recent analysis, the repository contains approximately 1,436 branches older than 24 months (as identified in GitHub Action logs). This cleanup policy addresses:
Implementation Details
🎯 Issue Template for Announcements
.github/ISSUE_TEMPLATE/branch_cleanup_announcement.yml🤖 Automated Cleanup Workflow
.github/workflows/branch-cleanup.yml🛡️ Protected Branch Patterns
The following branches are permanently protected from cleanup:
masterandmain- Main development branchesrelease*- All release branches (e.g.,releases/m158)Localize*andLocalization*- Localization branches📚 Documentation
docs/branch-cleanup-policy.md- Complete governance and proceduresdocs/branch-cleanup-README.md- Step-by-step usage instructionsBRANCH_CLEANUP_SUMMARY.md- Quick action items for maintainers🔄 Workflow Migration
branch-cleanup-preview.ymlwith deprecation noticeKey Features
✅ Automated Monthly Execution - No manual intervention required
✅ Safe Testing - Dry-run mode prevents accidental deletions
✅ Smart Protection - Pattern-based protection for critical branches
✅ Comprehensive Reporting - Automatic GitHub issue creation with cleanup details
✅ Flexible Configuration - Adjustable retention periods and options
✅ Error Recovery - Graceful handling of protected or missing branches
Usage
For Repository Maintainers
For Contributors
Security & Compliance
Testing
All YAML files have been validated for syntax correctness. The workflow includes:
This implementation provides a production-ready solution that balances automation efficiency with safety and transparency.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.