ci: add stale-branch audit workflow - #303
Open
drunkcoding wants to merge 1 commit into
Open
Conversation
Scheduled (weekly) audit that classifies remote branches vs the default branch as linear-merged, squash-merged, or unmerged (git cherry patch-id), and flags dead/stale unmerged branches by age. Scheduled runs are report-only in the job summary; deletion is opt-in via manual dispatch (mode=delete-merged + confirm=DELETE) and only removes provably-merged branches (linear or single-commit squash). Protected, open-PR, and unmerged branches are never deleted. Operationalizes PR_MERGE_POLICY.md section 4.
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
Adds a scheduled Stale Branches workflow (
.github/workflows/stale-branches.yml+.github/workflows/scripts/scan-stale-branches.sh) that audits remote branches against the default branch and reports which are merged (safe to delete) vs. dead/stale. Companion to #302 (docs/branch-maintenance.md), which documents the same classification method.Motivation
PR_MERGE_POLICY.md§4 requires "delete the PR branch once merged," but there is no automation enforcing it, so merged branches accumulate. This adds a low-risk, report-first job to surface them continuously.Type of Change
infra— build / CI / packaging / scripts / DockerFile changes
.github/workflows/stale-branches.yml.github/workflows/scripts/scan-stale-branches.shSafety model
reportmode onscheduleevents regardless of inputs.workflow_dispatchwithmode=delete-mergedandconfirm=DELETE.git cherrypatch-id). Multi-commit squash is report-only (manual review).main/master/release/*/release-*/hotfix/*), or branches with an open PR.git cherry(equivalent togit-delete-merged-branches --effort=3); same method as docs: branch audit + cleanup plan (linear vs squash, dead-branch scan) #302.Validated locally in report mode (
linear=7, squash1=51, squashN=44, dead=12, stale=24, active=37) and confirmed adelete-merged+confirm=DELETErequest on ascheduleevent performs no deletion.Checklist
PR Merge Policy Contract — pre-merge checklist
git diff --stat origin/mainreviewed; only the two intended files — no unrelated files.infra) ticked; both files are within theinfraset (CI / scripts).debug_*/check_*/scratch_*/tmp_*scripts added to a production package or repo root (the script lives under.github/workflows/scripts/).test_*.pyadded inside the runtime package.BATCHGEN_*env-var debug guard.print()or commented-out code in the changed files.-f.MODULE.mdupdate needed.Co-Authored-By.