Skip to content

Commit 4112a64

Browse files
committed
Use common GHA for deploy
1 parent d024089 commit 4112a64

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

.github/workflows/gcr-deploy.yaml

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,64 @@
1-
name: Build and deploy to Google Cloud Run
1+
name: deploy
22

33
on:
44
push:
55
branches:
6-
- master
6+
- main
7+
8+
workflow_dispatch:
79

810
# Environment variables available to all jobs and steps in this workflow
11+
# NOTE: these aren't really secret, but there aren't non-secret settings
912
env:
10-
PROJECT_ID: ${{ secrets.RUN_PROJECT }}
13+
RUN_PROJECT: ${{ secrets.RUN_PROJECT }}
1114
RUN_REGION: ${{ secrets.RUN_REGION }}
12-
SERVICE_NAME: ${{ secrets.RUN_SERVICE }}
15+
RUN_SERVICE: ${{ secrets.RUN_SERVICE }}
1316

1417
jobs:
15-
setup-build-deploy:
16-
name: Setup, Build, and Deploy
18+
deploy:
19+
name: Deploy to CloudRun
1720
runs-on: ubuntu-latest
1821

1922
steps:
2023
- name: Checkout
21-
uses: actions/checkout@v1
24+
uses: actions/checkout@v4
2225

23-
# Setup gcloud CLI
24-
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
26+
- name: gcloud auth
27+
id: 'auth'
28+
uses: 'google-github-actions/auth@v2'
2529
with:
26-
version: '275.0.0'
27-
service_account_email: ${{ secrets. GCP_SA_EMAIL }}
28-
service_account_key: ${{ secrets. GCP_SA_KEY }}
30+
credentials_json: '${{ secrets.GCP_SA_KEY }}'
2931

30-
# Configure gcloud CLI
31-
- name: gcloud Set up
32-
run: |
33-
gcloud config set project $PROJECT_ID
32+
# Setup gcloud CLI
33+
- name: gcloud setup
34+
uses: google-github-actions/setup-gcloud@v2
35+
36+
- name: gcloud docker-auth
37+
run: gcloud auth configure-docker
3438

3539
# Build and push image to Google Container Registry
3640
- name: Build
3741
run: |
3842
docker build \
3943
--build-arg COMMIT=${GITHUB_SHA:0:7} \
4044
--build-arg LASTMOD=$(date -u +%Y-%m-%dT%H:%M:%SZ) \
41-
--tag gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA .
45+
--tag gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
46+
.
4247
4348
- name: GCloud auth to docker
4449
run: |
4550
gcloud auth configure-docker
4651
4752
- name: Push to registry
4853
run: |
49-
docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA
54+
docker push gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA
5055
5156
# Deploy image to Cloud Run
5257
- name: Deploy
5358
run: |
54-
gcloud run deploy $SERVICE_NAME \
59+
gcloud run deploy ${RUN_SERVICE} \
5560
--allow-unauthenticated \
56-
--image gcr.io/$PROJECT_ID/$SERVICE_NAME:$GITHUB_SHA \
61+
--image gcr.io/${RUN_PROJECT}/${RUN_SERVICE}:$GITHUB_SHA \
5762
--platform managed \
58-
--project ${PROJECT_ID} \
59-
--region $RUN_REGION
63+
--project ${RUN_PROJECT} \
64+
--region ${RUN_REGION}

0 commit comments

Comments
 (0)