Skip to content

Branch Cleanup ​

Automatically delete branches that have been merged into the default branch.

How It Works ​

  1. Fetch all branches for a repository via GitHub API
  2. For each branch, check if it's been merged into the default branch
  3. Skip branches that match exclusion rules
  4. Delete remaining merged branches

Exclusion Rules ​

RuleWhat's excluded
Default branchThe repo's main branch (e.g. main, master)
Protected branchesBranches with branch protection enabled
Open PR branchesBranches with an associated open pull request
gitwire/* branchesAuto-generated branches still being processed

Trigger ​

bash
# Manual trigger
curl -X POST https://gitwire.yourdomain.com/api/maintainer/owner/repo/branch-cleanup \
  -H "Authorization: Bearer YOUR_API_KEY"

Configuration ​

Branch cleanup is enabled/disabled per repo via maintainer_settings:

json
{
  "cleanup_branches": true
}

Safety ​

  • Branches are only deleted if they have been fully merged into the default branch
  • The default branch is never deleted
  • Deletions are logged in maintainer_actions with action_type: "branch_cleanup"
  • Each deletion has a unique idempotency key

Actions Log ​

FieldValue
action_typebranch_cleanup
target_typebranch
target_numberBranch name
statusapplied or skipped

→ Settings API

Released under the MIT License.