Skip to content

Add automatic branch cleanup workflow - #8

Merged
loxdpsy merged 1 commit into
mainfrom
arena/36ef23ac-github
Nov 23, 2026
Merged

loxdpsy merged 1 commit into
mainfrom
arena/36ef23ac-github

Conversation

@loxdpsy

@loxdpsy loxdpsy commented Nov 23, 2026

Copy link
Copy Markdown
Member

Adds .github/workflows/branch-cleanup.yml, mirroring atlas-commerce's branch-cleanup.yml with two hardening changes.

Policy (same as atlas-commerce)

Trigger Action
PR closed (merged) delete the head branch
PR closed (not merged) delete only if the branch is fully contained in main
Weekly, Mondays 05:00 UTC sweep every branch that is fully merged into main and has no open PR — including leftover arena/* session branches
Manual dispatch same sweep, optional dry_run

What it never touches

  • main — skipped by name, resolved from the API rather than hardcoded
  • any branch with an open PR
  • any protected branch
  • any unmerged branch — nothing is force-deleted, rebased or rewritten

Differences from the atlas-commerce version

  1. dry_run input — manual runs can print WOULD DELETE without deleting. Useful to see what a first sweep would remove before letting it run weekly.
  2. Default branch resolved via API (repos/$REPO → .default_branch) instead of hardcoding main, and the PR-close step also skips protected branches — the atlas version checks protection only in the sweep.

Everything else is deliberately identical, including the / → %2F escaping for arena/... branch names and set -euo pipefail.

Verified

  • YAML parses; triggers, permissions and inputs confirmed
  • every run: block passes bash -n
  • current state of this repo: only main exists, no open PRs — so the first sweep is a no-op until session branches accumulate

Note

The workflow uses the default GITHUB_TOKEN with contents: write. If branch protection on main blocks the Actions bot, deletions are skipped with a logged message rather than failing the job.

Same policy as atlas-commerce: delete a PR's head branch once it closes (when
merged, or fully contained in main), plus a Monday weekly sweep of branches
that are fully merged and have no open PR, including leftover arena/* branches.
Never touches main, branches with an open PR, protected branches, or unmerged
work. Adds a dry_run manual trigger the atlas version does not have.

Also documents it in the root README.

Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Nov 23, 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 15 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: QUIET
  • Plan: Advanced
  • Run ID: a1a177f7-9605-4e58-9d5f-b7712d361ba4
Commits

Reviewing files that changed from the base of the PR and between 23f45bf and b81465f.

Files selected for processing: 3

  • .github/workflows/branch-cleanup.yml
  • README.md
  • profile/README.md
  • Autofix · 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

@loxdpsy
loxdpsy merged commit 0f093e8 into main Nov 23, 2026
1 check passed
@github-actions
github-actions Bot deleted the arena/36ef23ac-github branch November 23, 2026 17:22
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