ci(maintenance): auto-merge Dependabot dev dependency updates - #5568
Open
svozza wants to merge 1 commit into
Open
ci(maintenance): auto-merge Dependabot dev dependency updates#5568svozza wants to merge 1 commit into
svozza wants to merge 1 commit into
Conversation
2 tasks
Closes the approve-and-merge toil for the narrow slice where review adds little: non-major bumps of direct npm development dependencies. Everything else is left untouched for a human. Three gates must agree before an approval is issued: the PR was opened by dependabot[bot] and is not from a fork, the update is an npm direct:development non-major bump, and every commit on the branch is authored by dependabot[bot] with a valid GitHub signature. The commit gate reads commits from the API rather than the event payload, so a commit pushed after the run starts is still caught. Two details are load-bearing and easy to get wrong: - fetch-metadata only verifies commits[0] and reads that commit's message for all metadata, so on a branch carrying extra history it can describe the wrong dependency entirely. The all-commits gate is what makes its output trustworthy. - An approval and an armed auto-merge outlive the run that granted them, and GitHub does not dismiss reviews when a branch is updated from its base. Without the withdrawal step, a PR that passed the gates once can merge after a later push fails them. This was reproduced in rehearsal: clicking "Update branch" landed a human-authored merge commit on main with the gate red, and the squashed result looked like a clean signed Dependabot commit. The withdrawal step only ever touches this workflow's own approvals and the auto-merge it enabled itself, never a maintainer's. This job's `auto-merge` context must be added to the required status checks for the withdrawal step to be backed by enforcement.
svozza
force-pushed
the
chore/dependabot-auto-merge
branch
from
August 19, 2026 12:27
56bc64c to
9706bce
Compare
svozza
marked this pull request as ready for review
August 19, 2026 12:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Dependabot opens daily pull requests that maintainers approve by hand, and because
mainuses strict status checks withdismiss_stale_reviews, every merge invalidates the others and restarts the cycle. This automates approval and merge for the narrow slice where review adds little — non-major bumps of direct npm development dependencies — and leaves everything else for a human.Rehearsed end to end on a private staging fork against live Dependabot pull requests, including the negative cases.
Changes
.github/workflows/dependabot-auto-merge.yml, triggered onpull_request(neverpull_request_target), withpermissions: {}at workflow level. It never checks out or executes pull request codedependabot[bot]and is not from a fork, the update is an npmdirect:developmentnon-major bump, and every commit on the branch is authored bydependabot[bot]with a valid GitHub signaturedependabot/fetch-metadatato25dd0e34f4fe68f24cc83900b1fe3fe149efef98(v3.1.0)Why the withdrawal step exists
An approval and an armed auto-merge outlive the run that granted them, and GitHub does not dismiss reviews when a branch is updated from its base — the diff is unchanged, so the approval survives. In rehearsal this let a pull request merge after it stopped qualifying: the workflow approved a clean head, "Update branch" then added a merge commit authored by a human, the commit gate correctly went red, and the pull request merged anyway because nothing revoked the earlier approval. The squashed result on
mainlooked like an ordinary signed Dependabot commit.dependabot/fetch-metadataalso verifies onlycommits[0]and reads that commit's message for all metadata, so on a branch carrying extra history it can report the wrong dependency entirely. The all-commits gate is what makes its output trustworthy.Rollout order
This job's
auto-mergecontext must be a required status check, otherwise a red gate blocks nothing. Safe for human pull requests: the job is skipped for them and reportsskipped, which GitHub counts as satisfied.run-unit-tests / unit-tests-completeanddependency-reviewto the required status checks formainauto-mergehas reported on any pull request, add it to the required status checks. Not before this pull request merges — until the workflow is onmainthe context never reports, and every unrelated pull request would sit blocked waiting for itallow_auto_merge: trueon the repositoryKeeping
allow_auto_mergedisabled until step 5 is the interlock: nothing can auto-merge while the gate is unenforced. Between steps 3 and 5, an in-scope Dependabot pull request will be approved and then have that approval withdrawn when arming fails, leaving a redauto-mergecheck. Harmless, and it stops as soon as step 5 is done.Scope caveat worth knowing
Dependabot derives
dependency-typefrom npm's production tree inpackage-lock.json, not from which section ofpackage.jsondeclares a dependency.typescript,@types/nodeandesbuildtherefore reportdirect:productionand will not auto-merge —typescriptbecausevalibot, a production dependency, declares an optional peer dependency on it. Grouped updates do auto-merge when the group is dev-only and non-major, which is worth knowing given thetypescriptandvitestgroups independabot.yml.Issue number: closes #5491
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.