Skip to content

ci: publish coder-preview through coder/ghcr-publisher - #32571

Merged
kylecarbs merged 1 commit into
mainfrom
ci-preview-ghcr-publisher
Nov 22, 2026
Merged

kylecarbs merged 1 commit into
mainfrom
ci-preview-ghcr-publisher

Conversation

@kylecarbs

@kylecarbs kylecarbs commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

The problem. Any workflow on any branch here can push ghcr.io/coder/coder-preview, because GitHub grants package write per repository. coder/dogfood's Flux (coder-image/resourcesetinputprovider-coder-preview.yaml) deploys the alphabetically newest main-<10 digits>-<12 hex> tag every 2 minutes, with no signature check. So a writer can push main-9999999999-… from a branch, and dogfood runs it within minutes and stays on it.

The fix. It follows the release flow in #32566:

  • build.yaml pushes to coder-preview-staging.
    • Each per-arch digest comes from the registry's response to its own docker push, and the index is built from those digests. No staging tag is read back, which closes a race where a writer swaps a tag mid-build.
  • It signs a preview attestation (https://coder.com/attestations/preview/v1: commit, version tag, target). This step must succeed.
  • It dispatches coder/ghcr-publisher (promote-preview.yaml) with a coder-ghcr-dispatch token (contents: write on ghcr-publisher only), revokes the token, and waits for the version tag and, on main, the main-<commit time>-<sha> tag.
  • The publisher verifies the attestation came from a push run of build.yaml on main or release/* at that run's head commit. It then derives every public tag from the verified commit: the version, main-<commit time>-<sha>, main, latest and release-X.Y.
    • The derived tag matches today's main-1795210592-ecc0850e369a exactly, so dogfood's filter keeps working.
    • Rolling tags only move forward.
  • Pruning now targets the staging package. Public package storage is free, and only the publisher can write the public one.
  • SBOM and provenance attestations now run on the digest, once, instead of once per tag.

Prerequisites (all done 2026-11-22)

  • coder/ghcr-publisher#2 merged
  • The coder-ghcr-dispatch App exists (coder/gcp#472, coder/github-org-terraform#206). The ci-signing environment has CODER_GHCR_DISPATCH_APP_ID, CODER_GHCR_DISPATCH_APP_KMS_KEY and APP_KEYS_WORKLOAD_ID_PROVIDER.
  • coder-preview-staging exists: coder/coder Admin (pushes and prunes), ghcr-publisher Read
  • ghcr-publisher has Write on coder-preview

After the first successful promotion: set coder/coder to Read on coder-preview. Only then is the dogfood path closed. Pruning coder-preview moves to coder/ghcr-publisher (prune-preview.yaml, which has Admin on that package); this PR points the prune job here at coder-preview-staging.

actionlint and zizmor are clean. The push and index steps were rehearsed on a local registry, where the parsed digests matched what the registry stored.

🤖 Generated with Claude Code

Any workflow on any branch here could push ghcr.io/coder/coder-preview,
and dogfood's Flux deploys the newest main-<time>-<sha> tag every two
minutes without verifying it. A writer could push main-9999999999-x and
dogfood would run it within minutes.

build.yaml now pushes to coder-preview-staging, with digests taken from
the registry's response to each push and the index built from them,
attests the build with a preview attestation (commit, version tag,
target), and dispatches coder/ghcr-publisher with a coder-ghcr-dispatch
token. The publisher verifies the attestation and the push run, then
derives every public tag from the verified commit. The prune job now
prunes the staging package.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@kylecarbs
kylecarbs marked this pull request as ready for review November 22, 2026 16:35
@kylecarbs
kylecarbs requested a review from a team November 22, 2026 16:35
@kylecarbs
kylecarbs merged commit 325fbc2 into main Nov 22, 2026
62 checks passed
@kylecarbs
kylecarbs deleted the ci-preview-ghcr-publisher branch November 22, 2026 16:42
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 22, 2026

This branch had an error being deployed

1 failed deployment
docs-preview — 4e6c1837 Deployed Nov 22, 2026 by kylecarbs via cleanup #324
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants