feat: add shared registry push - #43
Conversation
This adds steps to push to the shared registry in the WanAware shared GCP project. We must first run the logic to push to the shared registry so that steps following the build/push steps use the original authentication mechanism. All steps to push to the shared registry are allowed to fail so that existing workflows are not impacted by this new change.
This was added to ensure that we continue on error if something goes wrong with the shared image build (e.g. missing env var settings) as we do not want to affect the current workflow.
Greptile SummaryThis PR adds steps to push built Docker images to a separate shared GCP project registry so that a wanaware-operator service can pull and run them. The changes restructure the existing auth/build/push sequence to authenticate with the shared GCP account first, tag the already-built image for the shared registry, push it, then re-authenticate with the standard account to proceed as before.
Confidence Score: 3/5Safe to merge only if no calling Dockerfile uses a private base image from the standard GCP registry; otherwise every build referencing a private FROM image will fail. The restructuring moved gcloud auth configure-docker to after the Docker build step. Any Dockerfile that pulls a private base image from the standard registry at build time will now fail with an auth error, a regression from pre-PR behaviour. .github/workflows/deployment.yaml — specifically the ordering of the standard configure-docker step relative to the Build Docker image step. Important Files Changed
|
Signed-off-by: scottlee01818 <scott.lee01818@gmail.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Signed-off-by: scottlee01818 <scott.lee01818@gmail.com>
muhammad-tahir-nawaz
left a comment
There was a problem hiding this comment.
Left a few comments. Main concern is that this isn't additive as-is - the standard auth block moving after the build changes behaviour for existing callers.
| # this build/push (e.g. GKE deploy) use the normal gcloud credentials. | ||
| # all steps related to the shared account are allowed to fail so | ||
| # that existing workflows are not impacted. | ||
| - name: Authenticate with GCP Shared Account |
There was a problem hiding this comment.
This isn't additive - the standard Authenticate with GCP / Set up gcloud / configure-docker block has been moved from before the build to after Trivy. Since the shared auth that now precedes the build is continue-on-error: true, any repo that hasn't set the four _SHARED secrets will reach Build Docker image with no gcloud credentials and no docker credential helper configured at all. Any Dockerfile with a FROM ${GCP_REGISTRY}/... base image, or any build pulling from GAR, will break where it works today.
Can we keep the original standard-auth block in its original position (before the build) and add the shared auth block as new steps after the build, right before the shared tag/push, then re-auth to standard before Push Docker image? That keeps the change genuinely additive for every existing caller.
| # this build/push (e.g. GKE deploy) use the normal gcloud credentials. | ||
| # all steps related to the shared account are allowed to fail so | ||
| # that existing workflows are not impacted. | ||
| - name: Authenticate with GCP Shared Account |
There was a problem hiding this comment.
Related to the above: google-github-actions/auth writes GOOGLE_APPLICATION_CREDENTIALS into the workspace and gcloud auth configure-docker writes ~/.docker/config.json. On ephemeral ARC pods that's re-created per run so re-authenticating is clean, but on a non-ephemeral self-hosted runner the shared credentials could linger between runs and leak into an unrelated job. Can you confirm every consumer of this reusable workflow is on ephemeral runners?
| ${{ secrets.GCP_REGISTRY }}/${{ secrets.GCP_PROJECT }}/${{ inputs.image_path }}:latest \ | ||
| ${{ secrets.GCP_REGISTRY_SHARED }}/${{ secrets.GCP_PROJECT_SHARED }}/${{ inputs.image_path }}:latest | ||
|
|
||
| # only a single scan is required since both images are identical with different tags |
There was a problem hiding this comment.
Small clarity point - this comment sits above Trivy but the retag happens before it and the shared push after it. Worth rewording to say the scan gates both pushes, so it's clear the shared image is covered by the same gate rather than being scanned separately.
Summary
This adds steps to push to the wanaware-shared project in GCP.
Why
This is required so that the operator being developed in the wanaware-operator project has appropriate permissions to pull and run the images required.
QA Report
Integration Tests
Added
Edited
Dependencies