Skip to content

Commit 16da774

Browse files
d-csclaude
andcommitted
ci: gate main-image dispatch on push events and make target configurable
Addresses review feedback: - The startsWith(github.ref_name, ...) gate would fire during release builds: release.yml invokes publish.yml via workflow_call with an explicit image_tag while github.ref_name is still `main`, so the job ran without CROSS_REPO_PAT and failed the release pipeline. Gate on github.event_name == 'push' — the intended paths (push to main, push of build-* tags) are push events; the release path is pull_request/workflow_dispatch. A version-equality check can't be used because build-* tags strip the prefix to the version output. - Make the dispatch target overridable via MAIN_IMAGE_DISPATCH_TARGET, defaulting to triggerdotdev/cloud. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d4d2619 commit 16da774

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

.github/workflows/publish.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,18 @@ jobs:
116116
image-ref: ${{ needs.publish-webapp.outputs.image_repo }}:${{ needs.publish-webapp.outputs.version }}
117117

118118
# Announce the freshly published mutable `main` webapp image to subscriber
119-
# repos in the org via repository_dispatch, handing them a digest-pinned ref to
120-
# build or deploy from. Fires only for the `main` tag — never semver releases or
121-
# other tag builds — and only from the canonical repo (forks have no PAT).
119+
# repos via repository_dispatch, handing them a digest-pinned ref to build or
120+
# deploy from. The repo, ref prefix, and dispatch target all default to the
121+
# canonical values and can be overridden by repository variables.
122+
#
123+
# `push` only: release builds reach publish.yml via workflow_call (from
124+
# release.yml) with an explicit image_tag while github.ref_name is still
125+
# `main`, so gate on the event to avoid dispatching — and failing on the
126+
# absent CROSS_REPO_PAT — during a release.
122127
dispatch-main-image:
123128
name: 📣 Dispatch main image
124129
needs: [publish-webapp]
125-
if: github.repository == (vars.MAIN_IMAGE_DISPATCH_REPO || 'triggerdotdev/trigger.dev') && startsWith(github.ref_name, vars.MAIN_IMAGE_DISPATCH_REF_PREFIX || 'main')
130+
if: github.repository == (vars.MAIN_IMAGE_DISPATCH_REPO || 'triggerdotdev/trigger.dev') && github.event_name == 'push' && startsWith(github.ref_name, vars.MAIN_IMAGE_DISPATCH_REF_PREFIX || 'main')
126131
runs-on: ubuntu-latest
127132
permissions: {}
128133
steps:
@@ -153,6 +158,6 @@ jobs:
153158
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
154159
with:
155160
token: ${{ secrets.CROSS_REPO_PAT }}
156-
repository: triggerdotdev/cloud
161+
repository: ${{ vars.MAIN_IMAGE_DISPATCH_TARGET || 'triggerdotdev/cloud' }}
157162
event-type: main-image-published
158163
client-payload: ${{ steps.payload.outputs.client_payload }}

0 commit comments

Comments
 (0)