Skip to content

Commit 4cd77c1

Browse files
committed
chore: copy images from ghcr to enterprise GAR instead of rebuilding
1 parent ecb6bd0 commit 4cd77c1

1 file changed

Lines changed: 80 additions & 19 deletions

File tree

.github/workflows/mozcloud-publish.yaml

Lines changed: 80 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ jobs:
7373
TOKENSERVER_DATABASE_BACKEND=postgres
7474
should_tag_ghcr: true
7575

76-
build-and-push-syncserver-postgres-enterprise-gar:
76+
push-syncserver-postgres-enterprise-gar:
77+
needs: build-and-push-syncserver-postgres
7778
if: >
7879
github.event_name == 'workflow_dispatch' ||
7980
(
@@ -88,15 +89,44 @@ jobs:
8889
permissions:
8990
contents: read
9091
id-token: write
91-
packages: write
92-
uses: mozilla-it/deploy-actions/.github/workflows/build-and-push.yml@4784cb70739a4f32ce010921f60fb1ebbc791a38 # v6.2.2
93-
with:
94-
image_name: syncserver-postgres
95-
gar_name: fx-enterprise-private
96-
project_id: moz-fx-fx-enterprise-prod
97-
docker_build_args: |
98-
SYNCSTORAGE_DATABASE_BACKEND=postgres
99-
TOKENSERVER_DATABASE_BACKEND=postgres
92+
packages: read
93+
runs-on: ubuntu-latest
94+
steps:
95+
- name: Compute image tag
96+
id: tag
97+
run: |
98+
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
99+
echo "value=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
100+
else
101+
echo "value=${GITHUB_SHA:0:10}" >> "$GITHUB_OUTPUT"
102+
fi
103+
104+
- name: GCP auth
105+
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3
106+
with:
107+
workload_identity_provider: "projects/${{ vars.GCPV2_WORKLOAD_IDENTITY_POOL_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions"
108+
service_account: "${{ vars.SERVICE_ACCOUNT_NAME || 'artifact-writer' }}@moz-fx-fx-enterprise-prod.iam.gserviceaccount.com"
109+
token_format: access_token
110+
create_credentials_file: false
111+
112+
- name: Configure GAR
113+
run: gcloud auth configure-docker us-docker.pkg.dev --quiet
114+
115+
- name: Log in to ghcr
116+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
117+
with:
118+
registry: ghcr.io
119+
username: ${{ github.actor }}
120+
password: ${{ github.token }}
121+
122+
- name: Pull from ghcr, re-tag, push to enterprise GAR
123+
run: |
124+
TAG="${{ steps.tag.outputs.value }}"
125+
SRC="ghcr.io/$GITHUB_REPOSITORY/syncserver-postgres:${TAG}"
126+
DEST="us-docker.pkg.dev/moz-fx-fx-enterprise-prod/fx-enterprise-private/syncserver-postgres:${TAG}"
127+
docker pull "$SRC"
128+
docker tag "$SRC" "$DEST"
129+
docker push "$DEST"
100130
101131
# Note: we are moving towards renaming all images `syncserver`, the union of sync and tokenserver.
102132
# This presently remains for the time being to simplify deploys by maintaining `image_name: syncstorage-rs-spanner-python-utils`.
@@ -151,7 +181,8 @@ jobs:
151181
image_build_context: tools/postgres
152182
should_tag_ghcr: true
153183

154-
build-and-push-syncserver-postgres-python-utils-enterprise-gar:
184+
push-syncserver-postgres-python-utils-enterprise-gar:
185+
needs: build-and-push-syncserver-postgres-python-utils
155186
if: >
156187
github.event_name == 'workflow_dispatch' ||
157188
(
@@ -166,14 +197,44 @@ jobs:
166197
permissions:
167198
contents: read
168199
id-token: write
169-
packages: write
170-
uses: mozilla-it/deploy-actions/.github/workflows/build-and-push.yml@4784cb70739a4f32ce010921f60fb1ebbc791a38 # v6.2.2
171-
with:
172-
image_name: syncserver-postgres-python-utils
173-
gar_name: fx-enterprise-private
174-
project_id: moz-fx-fx-enterprise-prod
175-
dockerfile_path: tools/postgres/Dockerfile
176-
image_build_context: tools/postgres
200+
packages: read
201+
runs-on: ubuntu-latest
202+
steps:
203+
- name: Compute image tag
204+
id: tag
205+
run: |
206+
if [[ "$GITHUB_REF_TYPE" == "tag" ]]; then
207+
echo "value=$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
208+
else
209+
echo "value=${GITHUB_SHA:0:10}" >> "$GITHUB_OUTPUT"
210+
fi
211+
212+
- name: GCP auth
213+
uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3
214+
with:
215+
workload_identity_provider: "projects/${{ vars.GCPV2_WORKLOAD_IDENTITY_POOL_PROJECT_NUMBER }}/locations/global/workloadIdentityPools/github-actions/providers/github-actions"
216+
service_account: "${{ vars.SERVICE_ACCOUNT_NAME || 'artifact-writer' }}@moz-fx-fx-enterprise-prod.iam.gserviceaccount.com"
217+
token_format: access_token
218+
create_credentials_file: false
219+
220+
- name: Configure GAR
221+
run: gcloud auth configure-docker us-docker.pkg.dev --quiet
222+
223+
- name: Log in to ghcr
224+
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
225+
with:
226+
registry: ghcr.io
227+
username: ${{ github.actor }}
228+
password: ${{ github.token }}
229+
230+
- name: Pull from ghcr, re-tag, push to enterprise GAR
231+
run: |
232+
TAG="${{ steps.tag.outputs.value }}"
233+
SRC="ghcr.io/$GITHUB_REPOSITORY/syncserver-postgres-python-utils:${TAG}"
234+
DEST="us-docker.pkg.dev/moz-fx-fx-enterprise-prod/fx-enterprise-private/syncserver-postgres-python-utils:${TAG}"
235+
docker pull "$SRC"
236+
docker tag "$SRC" "$DEST"
237+
docker push "$DEST"
177238
178239
build-and-push-syncserver-mysql:
179240
if: >

0 commit comments

Comments
 (0)