Skip to content

Commit f67e0fe

Browse files
JohnMcLearclaude
andcommitted
ci: trigger release after Dependabot Automerge
GitHub Actions doesn't fire `on: push` workflows when the push is authenticated with GITHUB_TOKEN (intentional, to avoid recursive workflow loops). pascalgn/automerge-action only has GITHUB_TOKEN, so when it merges a Dependabot PR to default branch the resulting push doesn't trigger Node.js Package and the version-bump + npm-publish job never runs. Result: every Dependabot bump leaves an unreleased commit on default branch, the published npm version drifts behind, and the only way to ship is a human re-merge. Two coupled changes: - automerge.yml grows `actions: write` and a final step that calls `gh workflow run test-and-release.yml --ref <default-branch>`. Gated on automerge-action's `mergeResult == 'merged'` so it doesn't fire when nothing actually merged. - test-and-release.yml grows a `workflow_dispatch:` trigger so the above invocation has something to dispatch. Existing on:push is preserved unchanged. Mirrors ep_announce#114 (already merged and verified end-to-end). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 9dcdb99 commit f67e0fe

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

.github/workflows/automerge.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ name: Dependabot Automerge
22
permissions:
33
contents: write
44
pull-requests: write
5+
# `actions: write` lets the post-merge step kick off Node.js Package on
6+
# the default branch via `gh workflow run`. Without this, automerge'd
7+
# PRs land on main but the on-push release job never fires (GitHub
8+
# Actions intentionally suppresses on:push triggers when the push is
9+
# authenticated with GITHUB_TOKEN).
10+
actions: write
511
on:
612
workflow_run:
713
workflows:
@@ -21,10 +27,19 @@ jobs:
2127
uses: actions/checkout@v6
2228

2329
- name: Automerge
30+
id: automerge
2431
uses: "pascalgn/automerge-action@v0.16.4"
2532
env:
2633
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2734
MERGE_METHOD: squash
2835
MERGE_LABELS: ""
2936
MERGE_RETRY_SLEEP: "100000"
3037

38+
- name: Trigger release on default branch
39+
# `pascalgn/automerge-action` exits 0 whether or not it merged. Skip
40+
# the dispatch when nothing was actually merged so we don't kick a
41+
# phantom release run on every Dependabot Automerge invocation.
42+
if: steps.automerge.outputs.mergeResult == 'merged'
43+
env:
44+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
run: gh workflow run test-and-release.yml --ref ${{ github.event.repository.default_branch }}

.github/workflows/test-and-release.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Node.js Package
2-
on: [push]
2+
on:
3+
push:
4+
# Invoked by automerge.yml after a Dependabot PR is merged. GitHub
5+
# Actions doesn't fire on:push when the push is authored by GITHUB_TOKEN
6+
# (the automerge action's only available identity), so without this
7+
# dispatch trigger the release job never runs after auto-merges.
8+
workflow_dispatch:
39

410
# id-token: write must be granted here so the reusable npmpublish workflow
511
# can request an OIDC token for npm trusted publishing.

0 commit comments

Comments
 (0)