Skip to content

Commit 7abc05e

Browse files
committed
Fix Docker workflow not triggering after release
Replace the "release: published" trigger with "workflow_run" on the Release workflow. Events generated by GITHUB_TOKEN intentionally do not trigger other workflows, so the release published event from GoReleaser was silently ignored. workflow_run fires after the Release workflow completes and the job condition skips the build when the release failed or was cancelled. Tag is resolved via git describe --tags on the checked-out repo.
1 parent 33aeedc commit 7abc05e

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

.github/workflows/docker.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
name: Docker
22

33
on:
4-
release:
5-
types: [published]
4+
# Automatically run after the Release workflow completes successfully.
5+
# (Events created by GITHUB_TOKEN don't trigger "release: published" in
6+
# other workflows, so we use workflow_run instead.)
7+
workflow_run:
8+
workflows: ["Release"]
9+
types: [completed]
10+
# Manual trigger with an explicit tag.
611
workflow_dispatch:
712
inputs:
813
tag:
@@ -18,17 +23,31 @@ jobs:
1823
docker:
1924
name: Build and Push Docker Image
2025
runs-on: ubuntu-latest
26+
# Only run if the Release workflow succeeded (skip on failure/cancelled),
27+
# or if this was triggered manually.
28+
if: >-
29+
github.event_name == 'workflow_dispatch' ||
30+
github.event.workflow_run.conclusion == 'success'
2131
steps:
2232
- uses: actions/checkout@v6
33+
with:
34+
fetch-depth: 0
2335

2436
- name: Determine tag
2537
id: get_tag
2638
run: |
2739
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
2840
TAG="${{ inputs.tag }}"
2941
else
30-
TAG="${{ github.event.release.tag_name }}"
42+
# workflow_run: find the latest semver tag pointing at HEAD
43+
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
44+
fi
45+
46+
if [ -z "$TAG" ]; then
47+
echo "::error::Could not determine release tag"
48+
exit 1
3149
fi
50+
3251
echo "tag=$TAG" >> $GITHUB_OUTPUT
3352
echo "Using tag: $TAG"
3453

0 commit comments

Comments
 (0)