Skip to content

Fix Dependabot auto-merge by exempting dependency manifests from code owner review - #7019

Closed
amartinezfayo wants to merge 2 commits into
spiffe:mainfrom
amartinezfayo:dependabot-automerge-hardening
Closed

amartinezfayo wants to merge 2 commits into
spiffe:mainfrom
amartinezfayo:dependabot-automerge-hardening

Conversation

@amartinezfayo

Copy link
Copy Markdown
Member

The Dependabot auto-merge workflow has never successfully merged a PR. After CI passes, the workflow assigns the milestone and approves, but the merge step fails with GraphQL: Auto merge is not allowed for this repository (enablePullRequestAutoMerge). An example of a failure is here: https://github.com/spiffe/spire/actions/runs/26658532935

The root cause is that go.mod and go.sum fall under the * rule in CODEOWNERS, so the "require review from code owners" branch protection requirement is never satisfied by the workflow's github-actions[bot] approval. Because the PR can never become merge-ready, gh pr merge falls back to enabling auto-merge, which is a feature that is intentionally disabled on this repository.

This PR exempts /go.mod and /go.sum from code owner review using the documented CODEOWNERS pattern of leaving the owners empty. With that, a verified Dependabot PR meets all branch protection requirements as soon as the workflow approves it, and gh pr merge adds it directly to the merge queue, the same as clicking "Merge when ready". The "Allow auto-merge" repository setting remains disabled and the review process for every other PR is unchanged. The merge step now also retries briefly, since GitHub recomputes the mergeability state asynchronously after the approval is submitted.

The workflow now only approves and merges PRs whose changed files are limited to go.mod and go.sum. For other Dependabot PRs, such as github-actions ecosystem updates that modify workflow files, it assigns the milestone and leaves review and merge to the maintainers instead of failing at the merge step.

Security considerations:

  • No significant new attack vector is created for human-authored PRs. The workflow only approves and merges PRs that were opened by dependabot[bot] and contain exactly one commit cryptographically signed by Dependabot. A regular PR touching only go.mod and go.sum still requires an approving review from a collaborator with write access, and only a collaborator can add it to the merge queue. A PR touching go.mod together with any other file still requires code owner review, since ownership applies per file.
  • A new Module directive check step in the lint job rejects replace and exclude directives in go.mod, so a go.mod-only PR cannot redirect a module to a different source repository. This closes the one meaningful capability that removing the code owner requirement would otherwise add.
  • A 7-day Dependabot cooldown lets new upstream releases age before an update PR is opened, preserving a window for the ecosystem to detect and report a compromised release before it can land unattended. This mitigates the main residual supply chain exposure (a malicious version published upstream), which exists today as well, since routine version bumps are typically merged within a day or two of being opened. The cooldown applies to both the gomod and github-actions ecosystems.
  • The merge queue still revalidates CI before any PR lands, and the workflow re-verifies that the PR head SHA has not changed between commit verification and merge.

… owner review

Signed-off-by: Agustín Martínez Fayó <[email protected]>
Copilot AI review requested due to automatic review settings June 3, 2026 13:19
@amartinezfayo amartinezfayo added this to the 1.15.2 milestone Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts repository automation so Dependabot go.mod/go.sum patch/minor updates can be merged via the merge queue after CI passes, without enabling GitHub’s repository auto-merge feature and without changing review requirements for other file types.

Changes:

  • Exempts /go.mod and /go.sum from CODEOWNERS review requirements to unblock merge-queue merges driven by the workflow.
  • Adds CI enforcement to reject replace/exclude directives in go.mod to mitigate supply-chain redirection risk.
  • Updates the Dependabot auto-merge workflow to only approve/merge PRs that touch only go.mod/go.sum, and adds brief merge retries.
  • Adds a 7-day cooldown to Dependabot updates for both gomod and github-actions ecosystems.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
CODEOWNERS Exempts go.mod/go.sum from code owner review so automation can satisfy branch protections.
.github/workflows/pr_build.yaml Adds a lint-time check preventing replace/exclude directives in go.mod.
.github/workflows/dependabot_automerge.yml Detects manifest-only PRs, skips others, and retries merge-queue enrollment.
.github/dependabot.yml Adds Dependabot cooldown configuration for both update ecosystems.

Signed-off-by: Agustín Martínez Fayó <[email protected]>
@amartinezfayo

Copy link
Copy Markdown
Member Author

Closing in favor of #7070, which takes a different direction. We have decided to step back from automated Dependabot merges and switch to grouped weekly Dependabot PRs that maintainers review and merge by hand.

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