Skip to content

feat(dependabot-auto-merge): gate the workflow_run path on every required workflow - #94

Merged
nkg merged 1 commit into
mainfrom
feat/dependabot-merge-gate
Nov 18, 2026
Merged

nkg merged 1 commit into
mainfrom
feat/dependabot-merge-gate

Conversation

@nkg

@nkg nkg commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Summary

Moves the Dependabot merge gate into this reusable, so its eleven copies become one tested implementation.

Why: on the workflow_run path, the trigger fires once per workflow, so the first workflow to go green merged the PR while the others were still running. Callers on the default pull_request + --auto path were worse off: on private Free-plan repos there are no required checks, so --auto merged at once. On 2026-11-13, sproncy-website-scrapers #646 merged 11 seconds after its CI started, with tests failing, and broke main. Eleven Sproncy and HordiaLabs repos now carry an identical inline gate job to work around this.

New inputs (both default empty):

  • required-workflows: workflow filenames that must all have a successful pull_request run for the PR's head commit.
  • optional-workflows: path-filtered workflows. No run, or skipped, is fine; anything else must succeed.

How:

  • Gate job: a separate gate job that runs only when required-workflows is set, on the workflow_run path, for Dependabot. It fails closed: a missing required run, a running, failed, cancelled or skipped one, or an API error blocks the merge.
  • Permissions: gate declares no permissions, so it inherits the caller's job grant. Only callers that use it add actions: read. A permission declared in the reusable would be required from every caller, which would break the existing ones.
  • Merge job: auto-merge now has needs: gate and an always() guard. It runs if the gate was skipped (inputs empty, or the pull_request path) or passed. Its own permissions and steps are unchanged.

Backward compatible: with the inputs empty, gate is skipped and auto-merge behaves as before, so this can go out as a minor release (3.8.0).

Docs:

  • examples/README.md: the Free-plan stub now shows the gate, the branches filter, concurrency, and permissions: {} plus job grants.
  • CHANGELOG.md: an [Unreleased] entry.

Tests

  • New tests/dependabot-gate.test.sh extracts the gate's run: block verbatim and runs it against a fake gh, the same approach as plaintext-scan.test.sh. It has 13 cases: all passed, newline-separated input, failed, running, missing, skipped and cancelled required runs, a query error, missing, skipped, failed and running optional runs, and a name-prefix case. It is wired into self-test.yml.
  • Mutation checks: making any completed run pass fails 3 cases, and letting a missing required run pass fails 2.
  • actionlint (whole tree) and shellcheck pass.

After merging

  1. Tag v3.8.0. release.yml moves v3 and publishes the notes.
  2. Switch the eleven callers to required-workflows/optional-workflows, deleting their inline gate job. One PR each.

🤖 Generated with Claude Code

…ired workflow

A workflow_run trigger fires once per workflow, so the first one to go
green merged the PR while the others were still running, and on private
Free-plan repos nothing else stops it. Eleven callers had copied the same
inline gate job to fix that. Move it here as `required-workflows` (and
`optional-workflows` for path-filtered ones): a separate gate job checks
each listed workflow's run for the PR's head commit and fails closed.

The gate job declares no permissions, so only callers that use it need to
grant actions: read; with the inputs empty, nothing changes for anyone.

tests/dependabot-gate.test.sh runs the gate script verbatim against a fake
gh (13 cases), wired into self-test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@nkg
nkg marked this pull request as ready for review November 18, 2026 18:41
@nkg
nkg merged commit 037e7f7 into main Nov 18, 2026
13 checks passed
@nkg
nkg deleted the feat/dependabot-merge-gate branch November 18, 2026 19:03
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