Skip to content

Commit b3efa3f

Browse files
author
Christoph Henrici
committed
Enhanced cloud run deploy
1 parent d5a9aba commit b3efa3f

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/deploy-cloudrun.yml

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Deploy to Google Cloud Run (from GHCR image)
22

33
on:
4-
workflow_dispatch: {} # manual trigger via GitHub Actions tab
4+
workflow_dispatch: {}
55

66
env:
77
GCP_PROJECT_ID: clear-rock-477020-a0
@@ -20,24 +20,34 @@ jobs:
2020
- name: Checkout
2121
uses: actions/checkout@v4
2222

23-
# Authenticate to GCP using service account JSON secret
23+
# Auth to GCP with SA JSON in secret
2424
- name: Set up gcloud
2525
uses: google-github-actions/setup-gcloud@v2
2626
with:
2727
project_id: ${{ env.GCP_PROJECT_ID }}
2828
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
2929
export_default_credentials: true
3030

31+
# Configure Docker cred helper for Artifact Registry
3132
- name: Enable Artifact Registry docker auth
3233
run: gcloud auth configure-docker $GCP_REGION-docker.pkg.dev --quiet
3334

34-
- name: Pull from GHCR and Push to Artifact Registry
35+
# (Belt & suspenders) Explicit docker login to AR with OAuth token
36+
- name: Docker login to Artifact Registry
3537
run: |
36-
docker pull ghcr.io/chhex/spring-boot-react-crud-revisited2:latest
37-
docker tag ghcr.io/chhex/spring-boot-react-crud-revisited2:latest \
38-
$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$GAR_REPOSITORY/$IMAGE_NAME:latest
39-
docker push $GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$GAR_REPOSITORY/$IMAGE_NAME:latest
38+
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://$GCP_REGION-docker.pkg.dev
4039
40+
# Copy ONLY the amd64 variant from GHCR -> Artifact Registry
41+
- name: Setup crane
42+
uses: imjasonh/setup-crane@v0.4
43+
44+
- name: Copy GHCR → AR (amd64)
45+
run: |
46+
SRC=ghcr.io/chhex/spring-boot-react-crud-revisited2:latest
47+
DST=$GCP_REGION-docker.pkg.dev/$GCP_PROJECT_ID/$GAR_REPOSITORY/$IMAGE_NAME:latest
48+
crane cp --platform=linux/amd64 "$SRC" "$DST"
49+
50+
# Deploy to Cloud Run
4151
- name: Deploy to Cloud Run
4252
uses: google-github-actions/deploy-cloudrun@v2
4353
with:

0 commit comments

Comments
 (0)