Resolved GHCR image digest for PR preview deploys#27941
Conversation
Resolves the canonical sha256 digest for the freshly built pr-N image via an anonymous GHCR token + HEAD on the manifest, then forwards it as image_digest in the repository_dispatch payload to Ghost-Moya. Pinning the downstream Cloud Run deploy to a digest sidesteps GCP Artifact Registry's pull-through cache, which otherwise serves a stale manifest for the mutable pr-N tag and causes previews to deploy the prior image.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughThe PR preview workflow now includes logic to resolve an immutable image digest from GHCR when deploying eligible PRs. A new workflow step acquires an anonymous GHCR pull token, queries the PR-tagged image manifest via HTTP HEAD request, extracts the 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27941 +/- ##
=======================================
Coverage 73.81% 73.81%
=======================================
Files 1521 1521
Lines 128495 128495
Branches 15403 15403
=======================================
Hits 94848 94848
- Misses 32689 32713 +24
+ Partials 958 934 -24
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
PR preview deploys to Cloud Run have been occasionally serving stale images. The build job pushes a fresh image to GHCR as
ghcr.io/tryghost/ghost:pr-N, but the consumer side in Ghost-Moya pulls through GCP Artifact Registry, whose pull-through cache can lag behind GHCR for the mutablepr-Ntag. The result is a deploy that succeeds against an older manifest than the one we just built, and reviewers see a preview that does not reflect the latest commit.This change resolves the canonical sha256 digest from GHCR after the build job succeeds and forwards it to Ghost-Moya as
image_digestin therepository_dispatchpayload. The resolver fetches an anonymous pull token for the publictryghost/ghostrepo, issues a HEAD request against thepr-Nmanifest with the OCI index and Docker v2 manifest media types in the Accept header, and parses theDocker-Content-Digestresponse header. The digest is validated assha256:+ 64 hex chars before being written to the step output so a malformed or missing digest fails the job rather than dispatching garbage. The Ghost-Moya half of this change consumesimage_digestand pins the Cloud Run deploy to the immutable ref, sidestepping the Artifact Registry cache entirely.The token is acquired anonymously because the image is public, so no secrets are needed for the lookup. The skip guard from the recheck step is preserved so the digest resolve and dispatch are still gated together.