Repository navigation
ci: delete head branch after PR merge - #3
Merged
Merged
Conversation
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>
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.
Summary
Adds
.github/workflows/delete-merged-branch.yml: when a PR is merged, the workflow deletes its head branch viaGITHUB_TOKEN. This replaces manual cleanup of merged branches. No other files change.pull_request: closed. The job runs only whenmerged == trueand the head branch lives in this repository; fork PRs and closed-unmerged PRs are skipped.permissions: {}at workflow level; the single job getscontents: writeonly. No checkout, no third-party actions, no secrets beyondgithub.token(uses the runner's preinstalledgh).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.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.shis clean — not run locally (shellcheck not installed in the authoring environment); none of these files changed, CIshellcheckjob covers it../tests/run_tests.shpasses (run locally on this branch).Workflow checks: YAML parses; the step's script was run locally against a stubbed
ghfor 6 cases (default branch skipped,x?yrefused, delete OK, delete failed + branch exists → exit 1, delete failed + branch gone → OK, slashed Dependabot branch name → deleted). Noactionlintin the authoring environment. Bash repo; Pythoncompileall/pytestdo 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.
Signed-off-by:(DCO) present.Generated by Claude Code