Skip to content

Commit 2715217

Browse files
d-csclaude
andcommitted
ci: resolve image registry once in parent workflow
Per review feedback, resolve the target container registry namespace a single time in publish.yml (the orchestration workflow) and pass it down to every publish job as an image_registry input, rather than each child workflow independently computing the default. This also unifies on one override variable: webapp and workers now both key off IMAGE_REGISTRY (a namespace, e.g. ghcr.io/<owner>), with the webapp image living at <registry>/<repo-name>. The separate WEBAPP_IMAGE_REPO variable is dropped, removing the prior asymmetry between a full-path override for the webapp and a namespace override for workers. Children keep the vars.IMAGE_REGISTRY || ghcr.io/<owner> fallback so the worker workflows still resolve correctly on their direct push triggers. Upstream defaults are byte-identical (owner is triggerdotdev). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 7645e6d commit 2715217

4 files changed

Lines changed: 50 additions & 16 deletions

File tree

.github/workflows/publish-webapp.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ on:
1414
type: string
1515
required: false
1616
default: ""
17+
image_registry:
18+
description: The registry namespace to publish under (e.g. ghcr.io/<owner>)
19+
type: string
20+
required: false
21+
default: ""
1722
outputs:
1823
version:
1924
description: The published image tag
@@ -61,10 +66,10 @@ jobs:
6166
- name: 📛 Set the tags
6267
id: set_tags
6368
run: |
64-
# The image repo defaults to ghcr.io/<owner>/<repo>, so a fork publishes
65-
# to its own package automatically with no extra config. Set the
66-
# WEBAPP_IMAGE_REPO repository variable to override it with any
67-
# registry/path.
69+
# The registry namespace is resolved by the caller (defaulting to
70+
# ghcr.io/<owner>, overridable via the IMAGE_REGISTRY repository
71+
# variable); the webapp image lives at <registry>/<repo-name>. A fork
72+
# therefore publishes to its own package automatically.
6873
image_tags=$REF_WITHOUT_TAG:${STEPS_GET_TAG_OUTPUTS_TAG}
6974
7075
# when pushing the mutable main tag, also push an immutable-by-convention
@@ -76,7 +81,7 @@ jobs:
7681
echo "image_tags=${image_tags}" >> "$GITHUB_OUTPUT"
7782
echo "image_repo=${REF_WITHOUT_TAG}" >> "$GITHUB_OUTPUT"
7883
env:
79-
REF_WITHOUT_TAG: ${{ vars.WEBAPP_IMAGE_REPO || format('ghcr.io/{0}', github.repository) }}
84+
REF_WITHOUT_TAG: ${{ format('{0}/{1}', inputs.image_registry || vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner), github.event.repository.name) }}
8085
STEPS_GET_TAG_OUTPUTS_TAG: ${{ steps.get_tag.outputs.tag }}
8186
STEPS_GET_TAG_OUTPUTS_IS_SEMVER: ${{ steps.get_tag.outputs.is_semver }}
8287

.github/workflows/publish-worker-v4.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
type: string
99
required: false
1010
default: ""
11+
image_registry:
12+
description: The registry namespace to publish under (e.g. ghcr.io/<owner>)
13+
type: string
14+
required: false
15+
default: ""
1116
push:
1217
tags:
1318
- "re2-test-*"
@@ -65,15 +70,15 @@ jobs:
6570
- name: 📛 Set tags to push
6671
id: set_tags
6772
run: |
68-
# Defaults to ghcr.io/<owner>, so a fork publishes to its own namespace
69-
# automatically. Set the IMAGE_REGISTRY repository variable to publish
70-
# under a different ghcr.io namespace instead.
73+
# Resolved by the caller when invoked from publish.yml; falls back to the
74+
# IMAGE_REGISTRY repository variable (or ghcr.io/<owner>) for the direct
75+
# push triggers above, so a fork publishes to its own namespace.
7176
ref_without_tag=${IMAGE_REGISTRY}/${STEPS_GET_REPOSITORY_OUTPUTS_REPO}
7277
image_tags=$ref_without_tag:${STEPS_GET_TAG_OUTPUTS_TAG}
7378
7479
echo "image_tags=${image_tags}" >> "$GITHUB_OUTPUT"
7580
env:
76-
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
81+
IMAGE_REGISTRY: ${{ inputs.image_registry || vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
7782
STEPS_GET_REPOSITORY_OUTPUTS_REPO: ${{ steps.get_repository.outputs.repo }}
7883
STEPS_GET_TAG_OUTPUTS_TAG: ${{ steps.get_tag.outputs.tag }}
7984
STEPS_GET_TAG_OUTPUTS_IS_SEMVER: ${{ steps.get_tag.outputs.is_semver }}

.github/workflows/publish-worker.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
type: string
99
required: false
1010
default: ""
11+
image_registry:
12+
description: The registry namespace to publish under (e.g. ghcr.io/<owner>)
13+
type: string
14+
required: false
15+
default: ""
1116
secrets:
1217
DOCKERHUB_USERNAME:
1318
required: false
@@ -83,10 +88,10 @@ jobs:
8388
docker tag infra_image "$REGISTRY/$REPOSITORY:$IMAGE_TAG"
8489
docker push "$REGISTRY/$REPOSITORY:$IMAGE_TAG"
8590
env:
86-
# Defaults to ghcr.io/<owner>, so a fork publishes worker images to its
87-
# own namespace automatically. Set the IMAGE_REGISTRY repository variable
88-
# to publish under a different ghcr.io namespace instead.
89-
REGISTRY: ${{ vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
91+
# Resolved by the caller when invoked from publish.yml; falls back to the
92+
# IMAGE_REGISTRY repository variable (or ghcr.io/<owner>) for the direct
93+
# push triggers above, so a fork publishes to its own namespace.
94+
REGISTRY: ${{ inputs.image_registry || vars.IMAGE_REGISTRY || format('ghcr.io/{0}', github.repository_owner) }}
9095
REPOSITORY: ${{ steps.get_repository.outputs.repo }}
9196
IMAGE_TAG: ${{ steps.get_tag.outputs.tag }}
9297

.github/workflows/publish.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ env:
5353
AWS_REGION: us-east-1
5454

5555
jobs:
56+
# Resolve the target container registry namespace once and pass it down to every
57+
# publish job. Defaults to ghcr.io/<owner>, so a fork publishes to its own
58+
# namespace automatically; set the IMAGE_REGISTRY repository variable to override.
59+
resolve-registry:
60+
runs-on: ubuntu-latest
61+
outputs:
62+
registry: ${{ steps.resolve.outputs.registry }}
63+
steps:
64+
- name: 🧭 Resolve target registry
65+
id: resolve
66+
env:
67+
IMAGE_REGISTRY: ${{ vars.IMAGE_REGISTRY }}
68+
DEFAULT_REGISTRY: ghcr.io/${{ github.repository_owner }}
69+
run: |
70+
echo "registry=${IMAGE_REGISTRY:-$DEFAULT_REGISTRY}" >> "$GITHUB_OUTPUT"
71+
5672
typecheck:
5773
uses: ./.github/workflows/typecheck.yml
5874

@@ -63,7 +79,7 @@ jobs:
6379
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
6480

6581
publish-webapp:
66-
needs: [typecheck]
82+
needs: [typecheck, resolve-registry]
6783
permissions:
6884
contents: read
6985
packages: write
@@ -74,9 +90,10 @@ jobs:
7490
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
7591
with:
7692
image_tag: ${{ inputs.image_tag }}
93+
image_registry: ${{ needs.resolve-registry.outputs.registry }}
7794

7895
publish-worker:
79-
needs: [typecheck]
96+
needs: [typecheck, resolve-registry]
8097
permissions:
8198
contents: read
8299
packages: write
@@ -86,16 +103,18 @@ jobs:
86103
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
87104
with:
88105
image_tag: ${{ inputs.image_tag }}
106+
image_registry: ${{ needs.resolve-registry.outputs.registry }}
89107

90108
publish-worker-v4:
91-
needs: [typecheck]
109+
needs: [typecheck, resolve-registry]
92110
permissions:
93111
contents: read
94112
packages: write
95113
id-token: write
96114
uses: ./.github/workflows/publish-worker-v4.yml
97115
with:
98116
image_tag: ${{ inputs.image_tag }}
117+
image_registry: ${{ needs.resolve-registry.outputs.registry }}
99118

100119
# OS-level CVE scan of the image just published above. Report-only (writes to
101120
# the run summary); runs alongside the worker publishes and never blocks them.

0 commit comments

Comments
 (0)