Skip to content

Harden Dependabot auto-merge against races and workflow-file limits#10

Merged
kjake merged 1 commit into
masterfrom
claude/anchore-scan-job-debug-gtudoa
Jul 18, 2026
Merged

Harden Dependabot auto-merge against races and workflow-file limits#10
kjake merged 1 commit into
masterfrom
claude/anchore-scan-job-debug-gtudoa

Conversation

@kjake

@kjake kjake commented Jul 18, 2026

Copy link
Copy Markdown
Owner

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.yml

  1. Serialize with a concurrency group. 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. A concurrency: { group: dependabot-automerge, cancel-in-progress: false } queues the runs so each PR is handled against an up-to-date master.

  2. Merge commit instead of --squash. A squash re-authors the change as github-actions[bot]; when that change touches .github/workflows/**, GitHub refuses it with:

    refusing to allow a GitHub App to create or update workflow ... without `workflows` permission
    

    because GITHUB_TOKEN can't be granted the workflows scope. A merge commit keeps the edit in Dependabot's own commit, so the token never "writes" a workflow file and the merge is allowed.

  3. 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], targets master, 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

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
kjake marked this pull request as ready for review July 18, 2026 03:55
@kjake
kjake merged commit 2e40f05 into master Jul 18, 2026
2 checks passed
@kjake
kjake deleted the claude/anchore-scan-job-debug-gtudoa branch July 18, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants