Skip to content

ci: run the Dependabot auto-merge in the base branch context - #595

Merged
polaz merged 3 commits into
mainfrom
ci/dependabot-auto-merge-secrets
Sep 5, 2026
Merged

ci: run the Dependabot auto-merge in the base branch context#595
polaz merged 3 commits into
mainfrom
ci/dependabot-auto-merge-secrets

Conversation

@polaz

@polaz polaz commented Sep 5, 2026

Copy link
Copy Markdown
Member

Summary

Every Dependabot pull request here shows a failing auto-merge check: triggered on pull_request, the job receives Dependabot secrets instead of Actions secrets, so RELEASER_APP_ID resolves to an empty string and the App token step fails (The 'client-id' (or deprecated 'app-id') input must be set).

The workflow is replaced with the one already proven in structured-email-address and structured-public-domains: pull_request_target (base-branch context, where the secrets exist), no checkout at all, actions pinned to commits because that context can reach the App key, approval and auto-merge bound to the inspected head SHA, and auto-merge disarmed when someone other than Dependabot pushes to the branch.

Testing

Takes effect for Dependabot pull requests opened or updated after merge; the next @dependabot rebase on any open update exercises it.

Summary by CodeRabbit

  • Bug Fixes
    • Improved automated dependency update handling by verifying pull request source commits before approval or merge.
    • Prevented stale or moved pull requests from being automatically merged.
    • Added safeguards to disable auto-merge when unexpected actors or changes are detected.
  • Security
    • Restricted workflow permissions and pinned third-party actions to specific revisions for safer execution.

Triggered on pull_request the job receives Dependabot secrets, so
RELEASER_APP_ID is empty and the App token step fails on every
Dependabot pull request. Switch to pull_request_target, drop the
checkout that context must never do, pin the actions to commits, and
disarm auto-merge when someone other than Dependabot moves the head.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-05T17:08:34.723496Z 032b959 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 20 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 9e7b19f9-63e4-4d98-bf90-b2119a9d6d1e

📥 Commits

Reviewing files that changed from the base of the PR and between 5abd9f6 and 032b959.

📒 Files selected for processing (1)
  • .github/workflows/dependabot-auto-merge.yml

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 64ccaa14-2d4c-40e4-99ce-347e3bf8c8b8

📥 Commits

Reviewing files that changed from the base of the PR and between 515d271 and 5abd9f6.

📒 Files selected for processing (1)
  • .github/workflows/dependabot-auto-merge.yml

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The Dependabot auto-merge workflow now runs on pull_request_target, uses scoped and pinned credentials, cancels superseded runs, disarms stale auto-merge requests, and ties approval and merging to the inspected head commit.

Changes

Dependabot auto-merge workflow

Layer / File(s) Summary
Workflow trigger and execution controls
.github/workflows/dependabot-auto-merge.yml
The workflow uses pull_request_target, read-only default permissions, per-PR concurrency, and Dependabot author gating.
App token and metadata access
.github/workflows/dependabot-auto-merge.yml
The workflow creates a pinned App token with explicit write permissions. Metadata retrieval requires both the actor and triggering actor to be Dependabot.
Head validation and merge protection
.github/workflows/dependabot-auto-merge.yml
The workflow disables stale auto-merge requests, submits approval for the inspected head SHA, and merges with --match-head-commit.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 5abd9

Dependabot auto-merge now runs with the required base-branch secret access while pinning actions, limiting default permissions, and preventing approval or merge of a changed head commit. The change is ready to merge.

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant GitHubAPI
  participant PullRequest
  GitHubActions->>GitHubAPI: Read autoMergeRequest and headRefOid
  GitHubAPI->>PullRequest: Return auto-merge state and head SHA
  GitHubActions->>GitHubAPI: Disable auto-merge if the head changed
  GitHubActions->>GitHubAPI: Submit approval for the inspected head SHA
  GitHubActions->>PullRequest: Merge with the matching head commit
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: running the Dependabot auto-merge workflow in the base-branch context.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/dependabot-auto-merge-secrets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Sep 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

A rerun keeps github.actor as whoever caused the original event, so the
attempt counter and triggering_actor checks only made reruns skip both
paths: a failed disarm of a foreign push stayed armed, and a failed
Dependabot run could not be rerun into its approval.
@polaz
polaz enabled auto-merge (squash) September 5, 2026 17:03
@sonarqubecloud

sonarqubecloud Bot commented Sep 5, 2026

Copy link
Copy Markdown

@polaz
polaz merged commit 1692511 into main Sep 5, 2026
12 checks passed
@polaz
polaz deleted the ci/dependabot-auto-merge-secrets branch September 5, 2026 17:05

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 032b9590c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

# someone else, on the first attempt and on every rerun alike; a failed
# first attempt is retried into the same branch, not skipped.
- name: Disarm auto-merge when someone else moved the head
if: github.actor != 'dependabot[bot]'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Re-enable eligible PRs when a maintainer reopens them

When a maintainer reopens a Dependabot PR, github.actor is the maintainer even though the head did not move, so this condition selects the disarm path and the metadata step is subsequently skipped. Because reopened remains a configured trigger and closing a PR disarms auto-merge, an otherwise eligible reopened minor/patch update will never be approved or auto-merged until Dependabot happens to push another commit; distinguish reopened from a foreign synchronize event and evaluate the unchanged Dependabot head.

Useful? React with 👍 / 👎.

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.

1 participant