1+ name : deploy-artifact
2+ on :
3+ push :
4+
5+ jobs :
6+ docker-release :
7+ name : Tagged Docker release to Google Artifact Registry
8+ runs-on : ubuntu-latest
9+ if : github.event_name == 'push' && startsWith(github.ref, 'refs/tags') # only run when a tagged commit is pushed
10+
11+ permissions :
12+ contents : ' read'
13+ id-token : ' write'
14+
15+ steps :
16+ - name : Check out the repo
17+ uses : actions/checkout@v4
18+
19+ - id : ' auth'
20+ name : ' Authenticate to Google Cloud'
21+ uses : ' google-github-actions/auth@v2'
22+ with :
23+ token_format : access_token
24+ workload_identity_provider : ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
25+ service_account : ${{ secrets.SERVICE_ACCOUNT_EMAIL }}
26+ access_token_lifetime : 300s
27+
28+ - name : Login to Artifact Registry
29+ uses : docker/login-action@v1
30+ with :
31+ registry : us-central1-docker.pkg.dev
32+ username : oauth2accesstoken
33+ password : ${{ steps.auth.outputs.access_token }}
34+
35+ - name : Get tag
36+ id : get-tag
37+ run : echo ::set-output name=short_ref::${GITHUB_REF#refs/*/}
38+
39+ - name : Build and push Docker image
40+ uses : docker/build-push-action@v4
41+ with :
42+ context : .
43+ push : true
44+ tags : |
45+ us-central1-docker.pkg.dev/adventures-in-tech-world-0/tech-world-game-server-repo/tech-world-game-server-image:${{ steps.get-tag.outputs.short_ref }}
46+ us-central1-docker.pkg.dev/adventures-in-tech-world-0/tech-world-game-server-repo/tech-world-game-server-image:latest
47+
48+ - name : Deploy container image to Cloud Run
49+ id : ' deploy'
50+ uses : ' google-github-actions/deploy-cloudrun@v2'
51+ with :
52+ service : tech-world-game-server-service
53+ image : us-central1-docker.pkg.dev/adventures-in-tech-world-0/tech-world-game-server-repo/tech-world-game-server-image:latest
54+
55+ - name : ' Show url'
56+ run : ' echo "${{ steps.deploy.outputs.url }}"'
0 commit comments