-
Notifications
You must be signed in to change notification settings - Fork 0
66 lines (58 loc) · 1.67 KB
/
build-and-push-api.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Build and Push API
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'app/api/**'
- '.github/workflows/build-and-push-api.yaml'
pull_request:
types:
-opened
branches:
- main
paths:
- 'app/api/**'
workflow_run:
workflows: [Production Unit Tests]
types:
- completed
env:
TAG: prod
GAR: ${{ secrets.ARTIFACT_REGISTRY }}
CR_SERVICE: cloudrun-service-api
CR_REGION: northamerica-northeast2
jobs:
build-and-push-api:
name: build-and-push-api
runs-on: ubuntu-20.04
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
permissions:
contents: 'read'
id-token: 'write'
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v2
- id: auth
name: Authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
token_format: access_token
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ secrets.SERVICE_ACCOUNT }}
access_token_lifetime: 300s
- name: Login to Google Artifact Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: build-tag-push
run: |
export GAR=${{ env.GAR }}
make build-push-api ${{ env.TAG }}
- name: Redeploy Cloudrun Service
run: |
gcloud run services update ${{ env.CR_SERVICE }} --region=${{ env.CR_REGION }} --image=${{ env.GAR }}api:${{ env.TAG }}