Skip to content

Commit 03c4bc7

Browse files
author
Christoph Henrici
committed
Yet another try
1 parent b3efa3f commit 03c4bc7

File tree

1 file changed

+28
-21
lines changed

1 file changed

+28
-21
lines changed

.github/workflows/deploy-cloudrun.yml

Lines changed: 28 additions & 21 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: {}
4+
workflow_dispatch: {} # manual trigger via GitHub Actions tab
55

66
env:
77
GCP_PROJECT_ID: clear-rock-477020-a0
@@ -14,52 +14,59 @@ env:
1414
jobs:
1515
deploy:
1616
runs-on: ubuntu-22.04
17-
permissions:
18-
contents: read
1917
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v4
18+
- uses: actions/checkout@v4
2219

23-
# Auth to GCP with SA JSON in secret
24-
- name: Set up gcloud
20+
# 1) Authenticate with your JSON secret (GCP_CREDENTIALS)
21+
- name: Auth to Google Cloud
22+
uses: google-github-actions/auth@v2
23+
with:
24+
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
25+
26+
# 2) Install/initialize gcloud (no key here — auth already done)
27+
- name: Setup gcloud
2528
uses: google-github-actions/setup-gcloud@v2
2629
with:
27-
project_id: ${{ env.GCP_PROJECT_ID }}
28-
service_account_key: ${{ secrets.GCP_CREDENTIALS }}
30+
project_id: clear-rock-477020-a0
2931
export_default_credentials: true
3032

31-
# Configure Docker cred helper for Artifact Registry
32-
- name: Enable Artifact Registry docker auth
33-
run: gcloud auth configure-docker $GCP_REGION-docker.pkg.dev --quiet
33+
# (diagnostic – optional)
34+
- run: |
35+
gcloud config list account
36+
gcloud auth list
37+
38+
# 3) Configure Docker auth for Artifact Registry
39+
- name: Enable AR docker auth
40+
run: gcloud auth configure-docker europe-west6-docker.pkg.dev --quiet
3441

35-
# (Belt & suspenders) Explicit docker login to AR with OAuth token
42+
# 4) Explicit docker login (now the token exists)
3643
- name: Docker login to Artifact Registry
3744
run: |
38-
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://$GCP_REGION-docker.pkg.dev
45+
gcloud auth print-access-token | docker login -u oauth2accesstoken --password-stdin https://europe-west6-docker.pkg.dev
3946
40-
# Copy ONLY the amd64 variant from GHCR -> Artifact Registry
47+
# 5) Copy ONLY amd64 from GHCR Artifact Registry
4148
- name: Setup crane
4249
uses: imjasonh/setup-crane@v0.4
4350

4451
- name: Copy GHCR → AR (amd64)
4552
run: |
4653
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
54+
DST=europe-west6-docker.pkg.dev/clear-rock-477020-a0/app/spring-react-crud:latest
4855
crane cp --platform=linux/amd64 "$SRC" "$DST"
4956
50-
# Deploy to Cloud Run
57+
# 6) Deploy to Cloud Run
5158
- name: Deploy to Cloud Run
5259
uses: google-github-actions/deploy-cloudrun@v2
5360
with:
54-
service: ${{ env.SERVICE_NAME }}
55-
region: ${{ env.GCP_REGION }}
56-
image: ${{ env.GCP_REGION }}-docker.pkg.dev/${{ env.GCP_PROJECT_ID }}/${{ env.GAR_REPOSITORY }}/${{ env.IMAGE_NAME }}:latest
61+
service: spring-react-crud
62+
region: europe-west6
63+
image: europe-west6-docker.pkg.dev/clear-rock-477020-a0/app/spring-react-crud:latest
5764
flags: |
5865
--port=8080
5966
--allow-unauthenticated
6067
--memory=512Mi
6168
--max-instances=1
62-
--set-env-vars=SPRING_PROFILES_ACTIVE=${{ env.SPRING_PROFILES_ACTIVE }}
69+
--set-env-vars=SPRING_PROFILES_ACTIVE=demo
6370
6471
- name: Display Cloud Run URL
6572
run: |

0 commit comments

Comments
 (0)