Skip to content

ci(dependabot): make auto-merge work on private free-plan repos#30

Merged
walkindude merged 1 commit into
masterfrom
chore/dependabot-automerge-private
Jun 5, 2026
Merged

ci(dependabot): make auto-merge work on private free-plan repos#30
walkindude merged 1 commit into
masterfrom
chore/dependabot-automerge-private

Conversation

@walkindude

Copy link
Copy Markdown
Owner

Why

GitHub's native auto-merge (gh pr merge --auto) is unavailable on private repos on the free plan. The old dependabot-auto-merge.yml relied on it, so on this private repo --auto silently failed and low-risk Dependabot PRs piled up in the review queue with nothing merging them.

What

Replace the single auto-merge job with the visibility-agnostic label + workflow_run pattern:

  1. label (pull_request_target) — runs dependabot/fetch-metadata, then tags low-risk PRs with the dependabot-automerge label:
    • gomod patch
    • github_actions patch + minor
  2. merge (workflow_run, after the CI workflow succeeds) — does a plain gh pr merge --squash on the labeled Dependabot PR. A plain squash merge needs no native auto-merge, so it works on private and public repos alike.

Safety

  • Both jobs gate on github.event.pull_request.user.login == 'dependabot[bot]', not github.actor — a human @dependabot rebase makes the actor the commenter while the PR author stays Dependabot, so the actor check would wrongly fail.
  • No majors, ever. This repo groups Dependabot updates (gomod-patch = patch only, actions = patch + minor). For grouped PRs fetch-metadata reports the highest semver bump in the group, so gating on update-type keeps majors out even when a group collapses several bumps into one PR.
  • The merge job's workflow_run.workflows is pinned to the exact CI workflow name CI, which already triggers on pull_request — so the merge job fires only after green CI.

🤖 Generated with Claude Code

Replace the single `gh pr merge --auto` job with the visibility-agnostic
label + workflow_run pattern. GitHub native auto-merge is unavailable on
private free-plan repos, so `--auto` silently failed and Dependabot PRs
piled up.

The new flow: a `label` job (pull_request_target) runs fetch-metadata and
tags low-risk PRs (gomod patch, github_actions patch/minor) with
`dependabot-automerge`; a `merge` job (workflow_run after CI succeeds) does
a plain `gh pr merge --squash`, which needs no native auto-merge and works
on private and public repos alike.

The merge job's workflow_run gates on the exact CI workflow name `CI`.
Both jobs gate on `pull_request.user.login == 'dependabot[bot]'`, not
`github.actor`, so human-triggered rebases stay eligible. Grouped updates
are still safe: fetch-metadata reports the highest semver bump, so the
update-type gate keeps majors out.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@walkindude walkindude merged commit 00ab5ea into master Jun 5, 2026
8 checks passed
@walkindude walkindude deleted the chore/dependabot-automerge-private branch June 5, 2026 23:17
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