Skip to content

Commit 377380d

Browse files
committed
ci: modernize dependabot auto-merge (fix broken event filter)
The previous workflow gated on `workflow_run.event == 'push'`, but Dependabot PRs trigger CI via `pull_request`, not `push` — so the condition was always false and the job was silently skipped on every Dependabot PR. Replaced with the modern pattern: - Triggers on `pull_request` (the right event). - Uses `dependabot/fetch-metadata@v2` to classify the update. - Calls `gh pr merge --auto --squash`, which lets GitHub wait on branch-protection required status checks before merging. - Only patch and minor updates auto-merge. Majors stay manual. Prereqs (also being set on the repo): - `allow_auto_merge=true` at repo level. - Branch protection on main with required status checks for the CI `build` job and each of the Node.js Package driver matrix jobs, so a Dependabot PR cannot be auto-merged until the full driver suite and the lint/ts-check/build pipeline are green.
1 parent 76cc3d5 commit 377380d

1 file changed

Lines changed: 17 additions & 19 deletions

File tree

.github/workflows/automerge.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,27 @@
1-
name: Dependabot Automerge
1+
name: Dependabot auto-merge
2+
3+
on: pull_request
4+
25
permissions:
36
contents: write
47
pull-requests: write
5-
on:
6-
workflow_run:
7-
workflows:
8-
- CI
9-
types:
10-
- completed
118

129
jobs:
1310
automerge:
14-
if: >
15-
github.event.workflow_run.conclusion == 'success' &&
16-
github.event.workflow_run.event == 'push' &&
17-
github.event.workflow_run.actor.login == 'dependabot[bot]'
1811
runs-on: ubuntu-latest
12+
if: github.event.pull_request.user.login == 'dependabot[bot]'
1913
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v6
14+
- name: Fetch Dependabot metadata
15+
id: meta
16+
uses: dependabot/fetch-metadata@v2
17+
with:
18+
github-token: "${{ secrets.GITHUB_TOKEN }}"
2219

23-
- name: Automerge
24-
uses: "pascalgn/automerge-action@v0.16.4"
20+
- name: Enable auto-merge for patch and minor updates
21+
if: >-
22+
steps.meta.outputs.update-type == 'version-update:semver-patch' ||
23+
steps.meta.outputs.update-type == 'version-update:semver-minor'
24+
run: gh pr merge --auto --squash "$PR_URL"
2525
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
MERGE_METHOD: squash
28-
MERGE_LABELS: ""
29-
MERGE_RETRY_SLEEP: "100000"
26+
PR_URL: ${{ github.event.pull_request.html_url }}
27+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)