Harden Dependabot auto-merge against races and workflow-file limits#10
Merged
Conversation
Three PRs merged automatically on the first Dependabot batch, but the initial run also produced transient failures worth eliminating: - Serialize runs with a concurrency group. When several scans finished at once, their merge attempts raced: one won and the others failed against a base branch mid-recomputation. Queuing handles each PR against an up-to-date master. - Merge with a merge commit instead of --squash. A squash re-authors the change as github-actions[bot]; when it touches .github/workflows/**, GitHub refuses it because GITHUB_TOKEN lacks the (ungrantable) 'workflows' permission. A merge commit keeps the edit in Dependabot's own commit, so the token never writes a workflow file. - Retry the merge a few times to ride out transient mergeability recomputation immediately after another PR merges. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013s3Nae9FEoyZ4bmwMjMtvj
kjake
marked this pull request as ready for review
July 18, 2026 03:55
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.
Context
The first Dependabot batch (#5–#9) all auto-merged successfully, but the initial concurrent burst also produced transient auto-merge failures. This makes the merge step deterministic so future batches are clean and a workflow-editing PR can never be left stuck.
Changes to
.github/workflows/dependabot-automerge.ymlSerialize with a
concurrencygroup. When several scans finished within seconds of each other, their merge attempts raced — one won and the others failed against a base branch that was still recomputing mergeability. Aconcurrency: { group: dependabot-automerge, cancel-in-progress: false }queues the runs so each PR is handled against an up-to-datemaster.Merge commit instead of
--squash. A squash re-authors the change asgithub-actions[bot]; when that change touches.github/workflows/**, GitHub refuses it with:because
GITHUB_TOKENcan't be granted theworkflowsscope. A merge commit keeps the edit in Dependabot's own commit, so the token never "writes" a workflow file and the merge is allowed.Retry the merge up to 5 times with backoff, to ride out the brief window where a PR's mergeability is still being recomputed right after another PR merges.
Behavior unchanged
Still triggers only on a successful Anchore Container Scan, and still verifies the PR is from
dependabot[bot], targetsmaster, and that the scanned commit is still the PR head before merging. Branch is still deleted after merge.Testing
🤖 Generated with Claude Code
https://claude.ai/code/session_013s3Nae9FEoyZ4bmwMjMtvj
Generated by Claude Code