Repository navigation
ci: restore delete-branch-on-close workflow (actual root-cause fix) - #65
Merged
Merged
Conversation
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.
Đính chính PR #64
Sau khi đào sâu thêm với dữ liệu timeline thực tế, tôi nhận ra PR #64 đã chẩn đoán sai nguyên nhân. Đây là bản sửa đúng.
Nguyên nhân thực sự (đã chứng minh bằng dữ liệu)
Đây là bug lâu năm của GitHub: orgs/community#63409 — "PR branches merged by app installation tokens do not get deleted".
Bằng chứng từ repo này
merged_bygithub-actions[bot]SilverKnightKMACùng setting, cùng auto-merge, khác actor merge → khác kết quả.
PR #64 sai ở đâu
Đổi
branch: automated/update-managed-tools-${{ github.run_id }}chỉ ngăn việc ghi đè branch tên giống nhau giữa các tuần. Nó không sửa việc branch không bị xóa sau merge — bug áp dụng cho mọi branch khi merge bằng bot token. Kết quả: mỗi tuần vẫn sẽ tích lũy thêm 1 branch "mới" không bị xóa.Fix đúng
Khôi phục workflow
delete-branch-on-close.yml(đã thêm ở #63, đã xóa ở #64) — nó explicit xóa head branch khi PR close as merged, bypass bug của GitHub.Scope an toàn:
automated/*,dependabot/*,deps/*,chore/*hoặc tác giả là bot đáng tin.Kết luận
Hai layer phòng thủ:
Cảm ơn bạn đã không chấp nhận chẩn đoán vội — nó buộc tôi phải đào đến tận cùng nguyên nhân.