fix(ci): never auto-merge an untested head in dependabot-auto-merge#29
Merged
Conversation
Pass --match-head-commit to `gh pr merge` so the merge is refused if Dependabot rebases the PR after the test run we validated. Without it, a rebase between the test-result check and the merge could land an untested head on main. Add a 30-minute job timeout so the test-polling loop can't hang, and correct the rationale comment: main is protected (signed commits, linear history, PR required) but has no required status checks, which is why the test gate is enforced in this workflow rather than by branch protection.
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.
Problem
The dependabot auto-merge workflow validates that the test run for the PR's
head.shasucceeded, then merges. But between that check andgh pr merge, Dependabot can rebase the PR onto a new head. The merge would then land a head we never tested.The rationale comment was also stale — it claimed the workflow avoids branch protection because other workflows push directly to
main. That's no longer true: the style check is read-only and the changelog update is PR-based, andmainis protected.Fix
--match-head-commit "$HEAD_SHA"togh pr merge. If the head moved after validation, the merge is refused rather than landing an untested commit.timeout-minutes: 30to the job so the test-polling loop can't hang indefinitely.mainis protected (signed commits, linear history, PR required) but has no required status checks, so the test gate is enforced here in the workflow. A GitHub squash-merge keeps history linear and is signed.No behavioural change for the normal case (tests pass, head unchanged → merge proceeds); it only closes the rebase race.