Skip to content

Commit f756852

Browse files
committed
fix(ci): publish fork images and build caches in the owning registry
The relay, push-gateway, sprig, and chart workflows defaulted to ghcr.io/block/* names. In a fork, main pushes, tags, and same-repo pull requests then tried to push images, build caches, and charts into the upstream namespace, which the fork's GITHUB_TOKEN cannot write. Each default now derives from github.repository, and each consuming job lowercases the name before use. The GHCR_IMAGE, GHCR_PUSH_GATEWAY_IMAGE, GHCR_SPRIG_IMAGE, and GHCR_CHART_REPO variables still override the defaults. Provenance summaries name the owning repository. Signed-off-by: Tee8z <[email protected]>
1 parent ec8c28b commit f756852

4 files changed

Lines changed: 77 additions & 31 deletions

File tree

‎.github/workflows/docker.yml‎

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
name: Docker image
22

3-
# Builds and publishes the public Buzz relay images as ghcr.io/block/buzz.
3+
# Builds and publishes the public Buzz relay images as ghcr.io/<owner>/<repo>
4+
# (ghcr.io/block/buzz upstream) plus the matching -push-gateway image.
45
# Normal tags contain stripped binaries; matching debug-* tags contain the same
56
# optimized binaries with line-table debug information for native profilers.
67
#
@@ -77,10 +78,11 @@ concurrency:
7778
permissions: {}
7879

7980
env:
80-
# Single source of truth for the image name. Set GHCR_IMAGE as a repo
81-
# variable to override (e.g., for forks that want to push to their own
82-
# namespace without forking this file).
83-
IMAGE_NAME: ${{ vars.GHCR_IMAGE != '' && vars.GHCR_IMAGE || 'ghcr.io/block/buzz' }}
81+
# Single source of truth for the image names. Both default to the running
82+
# repository's namespace, so forks publish (and cache) in their own registry.
83+
# Set GHCR_IMAGE / GHCR_PUSH_GATEWAY_IMAGE as repo variables to override.
84+
IMAGE_NAME: ${{ vars.GHCR_IMAGE != '' && vars.GHCR_IMAGE || format('ghcr.io/{0}', github.repository) }}
85+
PUSH_GATEWAY_IMAGE: ${{ vars.GHCR_PUSH_GATEWAY_IMAGE != '' && vars.GHCR_PUSH_GATEWAY_IMAGE || format('ghcr.io/{0}-push-gateway', github.repository) }}
8486

8587
jobs:
8688
build:
@@ -104,6 +106,11 @@ jobs:
104106
arch: arm64
105107

106108
steps:
109+
- name: Normalize image names
110+
shell: bash
111+
run: |
112+
printf 'IMAGE_NAME=%s\nPUSH_GATEWAY_IMAGE=%s\n' "${IMAGE_NAME,,}" "${PUSH_GATEWAY_IMAGE,,}" >> "$GITHUB_ENV"
113+
107114
- name: Checkout
108115
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
109116
with:
@@ -330,6 +337,11 @@ jobs:
330337
tag_prefix: debug-
331338

332339
steps:
340+
- name: Normalize image names
341+
shell: bash
342+
run: |
343+
printf 'IMAGE_NAME=%s\nPUSH_GATEWAY_IMAGE=%s\n' "${IMAGE_NAME,,}" "${PUSH_GATEWAY_IMAGE,,}" >> "$GITHUB_ENV"
344+
333345
- name: Checkout source
334346
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
335347
with:
@@ -414,7 +426,7 @@ jobs:
414426
415427
- name: Attest provenance for the merged image
416428
# Sigstore-signed in-toto attestation, verifiable with:
417-
# gh attestation verify oci://ghcr.io/block/buzz:<tag> --owner block
429+
# gh attestation verify oci://<IMAGE_NAME>:<tag> --owner <repository owner>
418430
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
419431
with:
420432
subject-name: ${{ env.IMAGE_NAME }}
@@ -481,13 +493,13 @@ jobs:
481493
echo
482494
echo "Verify provenance:"
483495
echo '```'
484-
echo "gh attestation verify oci://${IMAGE_NAME}@${MERGED_DIGEST} --owner block"
496+
printf 'gh attestation verify oci://%s@%s --owner %s\n' "$IMAGE_NAME" "$MERGED_DIGEST" "$GITHUB_REPOSITORY_OWNER"
485497
echo '```'
486498
if [[ "$VARIANT" == "release" ]]; then
487499
echo
488500
echo "Verify deployment eligibility:"
489501
echo '```'
490-
echo "gh attestation verify oci://${IMAGE_NAME}@${MERGED_DIGEST} --repo block/buzz --signer-workflow block/buzz/.github/workflows/docker.yml --predicate-type https://buzz.block.xyz/attestations/deployment-eligibility/v1 --source-digest ${SOURCE_SHA}"
502+
printf 'gh attestation verify oci://%s@%s --repo %s --signer-workflow %s/.github/workflows/docker.yml --predicate-type https://buzz.block.xyz/attestations/deployment-eligibility/v1 --source-digest %s\n' "$IMAGE_NAME" "$MERGED_DIGEST" "$GITHUB_REPOSITORY" "$GITHUB_REPOSITORY" "$SOURCE_SHA"
491503
echo '```'
492504
fi
493505
} >> "$GITHUB_STEP_SUMMARY"
@@ -510,6 +522,11 @@ jobs:
510522
runner: ubuntu-24.04-arm
511523
arch: arm64
512524
steps:
525+
- name: Normalize image names
526+
shell: bash
527+
run: |
528+
printf 'IMAGE_NAME=%s\nPUSH_GATEWAY_IMAGE=%s\n' "${IMAGE_NAME,,}" "${PUSH_GATEWAY_IMAGE,,}" >> "$GITHUB_ENV"
529+
513530
- name: Checkout
514531
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
515532
with:
@@ -539,7 +556,7 @@ jobs:
539556
id: meta
540557
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
541558
with:
542-
images: ghcr.io/block/buzz-push-gateway
559+
images: ${{ env.PUSH_GATEWAY_IMAGE }}
543560
labels: |
544561
org.opencontainers.image.title=Buzz Push Gateway
545562
org.opencontainers.image.description=Capability-gated APNs last hop for Buzz
@@ -552,9 +569,9 @@ jobs:
552569
file: ./Dockerfile.push-gateway
553570
platforms: ${{ matrix.platform }}
554571
labels: ${{ steps.meta.outputs.labels }}
555-
outputs: type=image,name=ghcr.io/block/buzz-push-gateway,push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
556-
cache-from: type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:${{ matrix.arch }}
557-
cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref=ghcr.io/block/buzz-push-gateway-buildcache:{0},mode=max,compression=zstd', matrix.arch) || '' }}
572+
outputs: type=image,name=${{ env.PUSH_GATEWAY_IMAGE }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
573+
cache-from: type=registry,ref=${{ env.PUSH_GATEWAY_IMAGE }}-buildcache:${{ matrix.arch }}
574+
cache-to: ${{ (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) && format('type=registry,ref={0}-buildcache:{1},mode=max,compression=zstd', env.PUSH_GATEWAY_IMAGE, matrix.arch) || '' }}
558575
- name: Export digest
559576
if: github.event_name != 'pull_request'
560577
env:
@@ -614,6 +631,11 @@ jobs:
614631
id-token: write
615632
attestations: write
616633
steps:
634+
- name: Normalize image names
635+
shell: bash
636+
run: |
637+
printf 'IMAGE_NAME=%s\nPUSH_GATEWAY_IMAGE=%s\n' "${IMAGE_NAME,,}" "${PUSH_GATEWAY_IMAGE,,}" >> "$GITHUB_ENV"
638+
617639
- name: Download per-arch digests
618640
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
619641
with:
@@ -632,7 +654,7 @@ jobs:
632654
id: meta
633655
uses: docker/metadata-action@80c7e94dd9b9319bd5eb7a0e0fe9291e23a2a2e9 # v6.1.0
634656
with:
635-
images: ghcr.io/block/buzz-push-gateway
657+
images: ${{ env.PUSH_GATEWAY_IMAGE }}
636658
tags: |
637659
type=ref,event=branch,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }}
638660
type=sha,prefix=sha-,format=short,enable=${{ github.event_name != 'workflow_dispatch' || inputs.version == '' }}
@@ -646,15 +668,15 @@ jobs:
646668
run: |
647669
set -euo pipefail
648670
tags=(); while IFS= read -r tag; do [ -n "$tag" ] && tags+=("-t" "$tag"); done <<< "$META_TAGS"
649-
digests=(); for digest in *; do digests+=("ghcr.io/block/buzz-push-gateway@sha256:${digest}"); done
671+
digests=(); for digest in *; do digests+=("${PUSH_GATEWAY_IMAGE}@sha256:${digest}"); done
650672
docker buildx imagetools create "${tags[@]}" "${digests[@]}"
651673
first_tag=$(echo "$META_TAGS" | head -n1)
652674
digest=$(docker buildx imagetools inspect "$first_tag" --format '{{json .Manifest}}' | jq -r '.digest')
653675
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
654676
- name: Attest gateway image provenance
655677
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
656678
with:
657-
subject-name: ghcr.io/block/buzz-push-gateway
679+
subject-name: ${{ env.PUSH_GATEWAY_IMAGE }}
658680
subject-digest: ${{ steps.manifest.outputs.digest }}
659681
push-to-registry: true
660682
- name: Gateway publication summary
@@ -664,7 +686,7 @@ jobs:
664686
run: |
665687
set -euo pipefail
666688
{
667-
echo "### Published \`ghcr.io/block/buzz-push-gateway\`"
689+
echo "### Published \`${PUSH_GATEWAY_IMAGE}\`"
668690
echo
669691
printf "**Digest:** \`%s\`\n" "$GATEWAY_DIGEST"
670692
echo
@@ -675,6 +697,6 @@ jobs:
675697
echo
676698
echo 'Verify provenance before deployment:'
677699
echo "\`\`\`"
678-
printf 'gh attestation verify oci://ghcr.io/block/buzz-push-gateway@%s --owner block\n' "$GATEWAY_DIGEST"
700+
printf 'gh attestation verify oci://%s@%s --owner %s\n' "$PUSH_GATEWAY_IMAGE" "$GATEWAY_DIGEST" "$GITHUB_REPOSITORY_OWNER"
679701
echo "\`\`\`"
680702
} >> "$GITHUB_STEP_SUMMARY"

‎.github/workflows/helm-chart.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ permissions: {}
4646

4747
env:
4848
# Single source of truth for the OCI chart repository (helm appends the chart
49-
# name `buzz`, yielding oci://ghcr.io/block/buzz/charts/buzz, which is exactly
50-
# the install ref documented in deploy/charts/buzz/README.md). Set
51-
# GHCR_CHART_REPO as a repo variable to override (e.g., forks pushing to their
52-
# own namespace without editing this file) — mirrors docker.yml's GHCR_IMAGE.
53-
CHART_REPO: ${{ vars.GHCR_CHART_REPO != '' && vars.GHCR_CHART_REPO || 'oci://ghcr.io/block/buzz/charts' }}
49+
# name `buzz`, yielding oci://ghcr.io/<owner>/<repo>/charts/buzz; upstream
50+
# that is the install ref documented in deploy/charts/buzz/README.md). The
51+
# default follows the running repository so forks publish to their own
52+
# namespace. Set GHCR_CHART_REPO as a repo variable to override — mirrors
53+
# docker.yml's GHCR_IMAGE.
54+
CHART_REPO: ${{ vars.GHCR_CHART_REPO != '' && vars.GHCR_CHART_REPO || format('oci://ghcr.io/{0}/charts', github.repository) }}
5455

5556
jobs:
5657
lint-and-unittest:
@@ -165,6 +166,11 @@ jobs:
165166
contents: read
166167
packages: write # push the chart to GHCR
167168
steps:
169+
- name: Normalize chart repository
170+
shell: bash
171+
run: |
172+
printf 'CHART_REPO=%s\n' "${CHART_REPO,,}" >> "$GITHUB_ENV"
173+
168174
- name: Checkout
169175
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
170176
with:
@@ -241,7 +247,7 @@ jobs:
241247
CHART_REPO: ${{ env.CHART_REPO }}
242248
VERSION: ${{ steps.ver.outputs.version }}
243249
run: |
244-
# CHART_REPO is oci://ghcr.io/block/buzz/charts; helm push appends the
250+
# CHART_REPO is oci://ghcr.io/<owner>/<repo>/charts; helm push appends the
245251
# chart name, so the install ref is .../charts/buzz.
246252
INSTALL_REF="${CHART_REPO}/buzz"
247253
{

‎.github/workflows/push-gateway-helm-chart.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ on:
1818
- ".github/workflows/push-gateway-helm-chart.yml"
1919
permissions: {}
2020
env:
21-
CHART_REPO: oci://ghcr.io/block/buzz/charts
21+
# Defaults to the running repository's namespace so forks publish to their
22+
# own registry; GHCR_CHART_REPO overrides it (same variable as helm-chart.yml).
23+
CHART_REPO: ${{ vars.GHCR_CHART_REPO != '' && vars.GHCR_CHART_REPO || format('oci://ghcr.io/{0}/charts', github.repository) }}
2224
jobs:
2325
validate:
2426
runs-on: ubuntu-latest
@@ -41,6 +43,10 @@ jobs:
4143
contents: read
4244
packages: write
4345
steps:
46+
- name: Normalize chart repository
47+
shell: bash
48+
run: |
49+
printf 'CHART_REPO=%s\n' "${CHART_REPO,,}" >> "$GITHUB_ENV"
4450
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
4551
with:
4652
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.ref || '' }}

‎.github/workflows/sprig-image.yml‎

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
name: Sprig image
22

33
# Builds and publishes the public agent container image as
4-
# ghcr.io/block/buzz-sprig — the digest-pinned box the Kubernetes backend
5-
# deploys agents into (see Dockerfile.sprig and docs/remote-agents.md).
4+
# ghcr.io/<owner>/<repo>-sprig (ghcr.io/block/buzz-sprig upstream) — the
5+
# digest-pinned box the Kubernetes backend deploys agents into (see
6+
# Dockerfile.sprig and docs/remote-agents.md).
67
#
78
# Strategy mirrors docker.yml (the relay image): each architecture builds on
89
# its native runner, pushes to GHCR by digest, then a merge job stitches the
@@ -17,7 +18,7 @@ name: Sprig image
1718
# - workflow_dispatch → manual publish at the current ref
1819
#
1920
# NOTE: the first push creates the GHCR package PRIVATE by default. An org
20-
# admin must flip ghcr.io/block/buzz-sprig to public once (Package settings →
21+
# admin must flip the sprig package to public once (Package settings →
2122
# Change visibility). Subsequent pushes keep the visibility.
2223

2324
on:
@@ -46,9 +47,10 @@ concurrency:
4647
permissions: {}
4748

4849
env:
49-
# Single source of truth for the image name; override with the
50-
# GHCR_SPRIG_IMAGE repo variable (same pattern as docker.yml).
51-
IMAGE_NAME: ${{ vars.GHCR_SPRIG_IMAGE != '' && vars.GHCR_SPRIG_IMAGE || 'ghcr.io/block/buzz-sprig' }}
50+
# Single source of truth for the image name; it defaults to the running
51+
# repository's namespace so forks publish to their own registry. Override
52+
# with the GHCR_SPRIG_IMAGE repo variable (same pattern as docker.yml).
53+
IMAGE_NAME: ${{ vars.GHCR_SPRIG_IMAGE != '' && vars.GHCR_SPRIG_IMAGE || format('ghcr.io/{0}-sprig', github.repository) }}
5254

5355
jobs:
5456
build:
@@ -72,6 +74,11 @@ jobs:
7274
arch: arm64
7375

7476
steps:
77+
- name: Normalize image name
78+
shell: bash
79+
run: |
80+
printf 'IMAGE_NAME=%s\n' "${IMAGE_NAME,,}" >> "$GITHUB_ENV"
81+
7582
- name: Checkout
7683
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
7784
with:
@@ -156,6 +163,11 @@ jobs:
156163
attestations: write
157164

158165
steps:
166+
- name: Normalize image name
167+
shell: bash
168+
run: |
169+
printf 'IMAGE_NAME=%s\n' "${IMAGE_NAME,,}" >> "$GITHUB_ENV"
170+
159171
- name: Download per-arch digests
160172
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
161173
with:
@@ -213,7 +225,7 @@ jobs:
213225
echo "digest=${merged_digest}" >> "$GITHUB_OUTPUT"
214226
215227
- name: Attest provenance for the merged image
216-
# Verify with: gh attestation verify oci://ghcr.io/block/buzz-sprig:<tag> --owner block
228+
# Verify with: gh attestation verify oci://<IMAGE_NAME>:<tag> --owner <repository owner>
217229
uses: actions/attest-build-provenance@0f67c3f4856b2e3261c31976d6725780e5e4c373 # v4.1.1
218230
with:
219231
subject-name: ${{ env.IMAGE_NAME }}

0 commit comments

Comments
 (0)