Repository navigation
fix(ci): use unique branch name for update-managed-tools PR - #64
Merged
Merged
Conversation
The root cause of lingering branches was NOT that delete_branch_on_merge fails with auto-merge (that was my earlier, incorrect diagnosis). The repo setting works fine for Dependabot PRs, which use unique branch names per version bump. The real issue: update-managed-tools.yml reused a fixed branch name 'automated/update-managed-tools' across every weekly cron run. When that PR was merged and auto-deleted, the next cron push recreated the same branch, so it always appeared to linger. Switch to a run-id-suffixed branch name so each PR maps to a one-shot branch that GitHub's delete_branch_on_merge removes cleanly, matching the Dependabot pattern. Also drop the redundant delete-branch-on-close.yml workflow added in #63 - it is no longer needed now that the actual root cause is fixed.
SilverKnightKMA
added a commit
that referenced
this pull request
Jul 20, 2026
) PR #64 misdiagnosed the lingering branch as a side effect of reusing a fixed branch name. The real cause is a long-standing GitHub platform bug (orgs/community#63409): when a PR is merged via a bot/App token (actor: github-actions[bot]), the repo setting delete_branch_on_merge is silently ignored. User-merged PRs on the same repo delete fine. Evidence from this repo's timeline: - PRs #44, #45, #47, #55, #62 (merged_by=github-actions[bot]): no auto-delete; branches lingered until manually removed. - PRs #58, #59, #60 (merged_by=SilverKnightKMA): auto-deleted within 1 second of merge. Renaming the branch per run (PR #64) only stops branch reuse; it does not delete the merged branch. Without this workflow, merged branches would accumulate indefinitely one per week. This workflow explicitly deletes the head branch on PR close (merged), scoped to same-repo automation branches (automated/*, dependabot/*, deps/*, chore/*) or trusted bot authors. Fork branches are skipped and deletion is idempotent.
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.
Xin đính chính PR #63
Sau khi nhận feedback, tôi đã kiểm chứng lại và phát hiện chẩn đoán trong PR #63 là sai. Đây là bản sửa đúng.
Chẩn đoán sai (PR #63)
Chẩn đoán đúng (PR này)
Setting
delete_branch_on_merge: truehoạt động hoàn hảo với auto-merge. Bằng chứng từ chính repo:app/dependabotapp/silverknightkma-s-appCả hai cùng auto-merge, cùng setting. Sự khác biệt: tên branch.
dependabot/npm_and_yarn/typescript-7.0.2,dependabot/docker/debian-020c0d2).update-managed-tools.ymldùng branch name cố địnhautomated/update-managed-toolsqua mọi lần cron.Khi PR merge và branch bị auto-delete, lần cron kế tiếp
create-pull-requestpush commit lên cùng tên branch, tạo lại branch đã xóa → trông như branch ". mặc nhiên".Fix
branch: automated/update-managed-toolsthànhautomated/update-managed-tools-${{ github.run_id }}→ mỗi PR dùng branch một lần, giống Dependabot.delete-branch-on-close.yml(thêm ở PR ci: auto-delete head branch after merging automation PRs #63) — không cần nữa vì đã sửa đúng nguyên nhân.Verification