Skip to content

chore: add "stale branch" workflow - #6315

Merged
mark-wiemer merged 3 commits into
mainfrom
copilot/remove-stale-branches
Sep 15, 2026
Merged

mark-wiemer merged 3 commits into
mainfrom
copilot/remove-stale-branches

Conversation

Copilot AI commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Mocha’s repository policy is to keep the repo free of long-lived, unreviewed branches, while ensuring active work and protected branches remain intact. This adds a scheduled workflow to automatically remove branches that have been inactive for 7+ days and are not protected or associated with an open PR.

  • Workflow

    • Adds .github/workflows/stale-branches.yml
    • Runs daily via cron and can also be triggered manually
    • Skips main, 11.x, and any branch that is still the head of an open PR
    • Deletes stale branch refs via the GitHub API once they exceed the inactivity threshold
  • Safety

    • Uses repository-scoped permissioning to allow ref deletion only for the cleanup job
    • Filters out protected branches and active PR branches before deletion
    • Logs warnings instead of failing hard when a branch cannot be removed
# Example behavior
# main, 11.x -> retained
# feature/old-repro -> deleted after 7+ days with no open PR
# feature/active-pr -> retained while the PR is open

@linux-foundation-easycla

linux-foundation-easycla Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

CLA Not Signed

Copilot AI linked an issue Sep 15, 2026 that may be closed by this pull request
5 tasks done
Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>
Copilot AI changed the title [WIP] Automatically remove stale branches Add stale-branch cleanup automation Sep 15, 2026
Copilot AI requested a review from mark-wiemer September 15, 2026 14:04
@mark-wiemer

Copy link
Copy Markdown
Member

@copilot instead of deleting the branch, create an issue asking a maintainer to review the branch

Co-authored-by: mark-wiemer <7833360+mark-wiemer@users.noreply.github.com>

Copilot AI commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

@copilot instead of deleting the branch, create an issue asking a maintainer to review the branch

Updated the stale-branch workflow to open a maintainer review issue instead of deleting the branch directly. It skips protected branches and branches tied to open PRs, and avoids duplicate review issues. c102b8e

@mark-wiemer
mark-wiemer marked this pull request as ready for review September 15, 2026 14:35
@mark-wiemer mark-wiemer changed the title Add stale-branch cleanup automation chore: add "stale branch" workflow Sep 15, 2026
@mark-wiemer
mark-wiemer merged commit ad17f9f into main Sep 15, 2026
3 of 4 checks passed
@mark-wiemer
mark-wiemer deleted the copilot/remove-stale-branches branch September 15, 2026 14:36
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.

🛠️ Repo: Automatically remove stale branches

2 participants