Skip to content

ci: delete head branch after PR merge - #3

Merged
dzeusking-dev merged 1 commit into
mainfrom
claude/auto-delete-merged-branch
Oct 30, 2026
Merged

dzeusking-dev merged 1 commit into
mainfrom
claude/auto-delete-merged-branch

Conversation

@dzeusking-dev

Copy link
Copy Markdown

Summary

Adds .github/workflows/delete-merged-branch.yml: when a PR is merged, the workflow deletes its head branch via GITHUB_TOKEN. This replaces manual cleanup of merged branches. No other files change.

  • Trigger: pull_request: closed. The job runs only when merged == true and the head branch lives in this repository; fork PRs and closed-unmerged PRs are skipped.
  • Permissions: permissions: {} at workflow level; the single job gets contents: write only. No checkout, no third-party actions, no secrets beyond github.token (uses the runner's preinstalled gh).
  • The branch name is passed via env, never interpolated into the script. Names with characters outside [A-Za-z0-9._/-] are refused (they could change which ref the API path addresses). The default branch is never deleted. A branch already deleted (e.g. by hand) is not an error; a delete that fails while the branch still exists fails the job.
  • Protected branches stay protected: branch protection blocks deletion by GITHUB_TOKEN.

When this PR is merged, the workflow should delete this PR's own branch (claude/auto-delete-merged-branch), which is the first live check.

Verification

  • shellcheck port-guard.sh pm2-inventory.sh marker-healthcheck.sh adapters/*.sh tests/run_tests.sh is clean — not run locally (shellcheck not installed in the authoring environment); none of these files changed, CI shellcheck job covers it.
  • ./tests/run_tests.sh passes (run locally on this branch).
  • N/A: Any new fail-open path has a regression test — no tool code changed.

Workflow checks: YAML parses; the step's script was run locally against a stubbed gh for 6 cases (default branch skipped, x?y refused, delete OK, delete failed + branch exists → exit 1, delete failed + branch gone → OK, slashed Dependabot branch name → deleted). No actionlint in the authoring environment. Bash repo; Python compileall/pytest do not apply.

Safety

The tools themselves are untouched. The new workflow is the only writer: it deletes exactly one ref (the merged PR's head branch) and nothing else.

  • N/A: The change keeps the tools read-only — no tool code changed.
  • N/A: "No conflict found" / "confirmed owned" verdicts — no tool code changed.
  • Signed-off-by: (DCO) present.

Generated by Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016g7tG1cQPwg2coooARCpEQ
Signed-off-by: Claude <noreply@anthropic.com>
@dzeusking-dev
dzeusking-dev marked this pull request as ready for review October 30, 2026 19:57
@dzeusking-dev
dzeusking-dev merged commit f30f8ae into main Oct 30, 2026
4 checks passed
@github-actions
github-actions Bot deleted the claude/auto-delete-merged-branch branch October 30, 2026 19:58
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.

2 participants