Skip to content

ci(branch-cleanup): only delete the merged commit; keep heads of open PRs - #96

Closed
rishitank wants to merge 2 commits into
mainfrom
ci/branch-cleanup
Closed

rishitank wants to merge 2 commits into
mainfrom
ci/branch-cleanup

Conversation

@rishitank

Copy link
Copy Markdown
Owner

Why

#95 (the first version of branch-cleanup.yml) was auto-merged by auto-merge.yml at 01:44 UTC, before the second version reached its branch. This PR brings main up to that second version, which is already on every other repo's branch-cleanup PR and is proven live on rishitank/test#16.

What changed (.github/workflows/branch-cleanup.yml only)

  • Keeps a branch that is the head of another open PR (gh pr list --head), as well as one that is a base.
  • Deletes only the merged commit. Before deleting, the job reads the branch's current SHA and keeps the branch if it no longer equals pull_request.head.sha. A 404 means the branch is already gone, which counts as success. REST has no conditional delete, so only the sub-second gap between that read and the DELETE isn't covered; a comment in the workflow says so.
  • Each job permission has a comment saying why it's needed.

Note for this repo

Merges done by auto-merge.yml use GITHUB_TOKEN, and events created by GITHUB_TOKEN don't start other workflows. So when #95 was auto-merged, branch-cleanup didn't run, and ci/branch-cleanup survived (this PR reuses it). Auto-merged PRs here will keep their branches until auto-merge.yml merges with a PAT or GitHub App token, or someone merges them by hand.

🤖 Generated with Claude Code

https://claude.ai/code/session_012rYJxu978iUSGFZ1UuqTsi

rishitank and others added 2 commits October 9, 2026 02:35
GitHub has no account-wide setting for this, the per-repo toggle deletes
every merged head branch, and Free-plan private repos cannot protect
long-lived branches such as develop. This self-contained workflow runs
on merged same-repo PRs and deletes the head branch unless it is the
default branch, one of main/master/develop/staging/test/gh-pages/
deploy-*/release/*, or the base of another open PR. A branch that is
already gone counts as success.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012rYJxu978iUSGFZ1UuqTsi
… PRs

From CodeRabbit review: keep the branch when another open PR uses it as
its head; read the branch's current SHA first and keep it if it moved
past the merged PR head (REST has no conditional delete, so only the
instant between read and DELETE is unguarded); comment each permission.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012rYJxu978iUSGFZ1UuqTsi
@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 40 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: a2f56d94-9093-4db9-8c2a-4a05d677b0f6
📥 Commits

Reviewing files that changed from the base of the PR and between fee29ab and 3413cc5.

📒 Files selected for processing (1)
  • .github/workflows/branch-cleanup.yml
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rishitank

Copy link
Copy Markdown
Owner Author

Closing as redundant. Merged branches are now handled account-wide by the nightly branch-prune workflow in rishitank/.github (it also switches on Automatically delete head branches for every repository), so a per-repository workflow isn't needed and would spend Actions minutes in private repositories. Closed, not merged; the branch is left in place.

🤖 Generated with Claude Code

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.

1 participant