Skip to content

Commit ec0e5d5

Browse files
JohnMcLearclaude
andauthored
ci: trigger release after Dependabot Automerge (#93)
GitHub Actions doesn't fire on:push when GITHUB_TOKEN authors the push. Mirrors ep_announce#114. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 030a32a commit ec0e5d5

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)