-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 1.67 KB
/
build-and-push-web.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
name: Build and Push Web
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "app/web/**"
- ".github/workflows/build-and-push-web.yaml"
pull_request:
types: -opened
branches:
- main
paths:
- "app/web/**"
env:
TAG: prod
GAR: ${{ secrets.ARTIFACT_REGISTRY }}
CR_SERVICE: project-ct
CR_REGION: northamerica-northeast2
jobs:
build-and-push-web:
name: build-and-push-web
runs-on: ubuntu-20.04
permissions:
contents: "read"
id-token: "write"
steps:
- id: checkout
name: Checkout
uses: actions/checkout@v4
- id: auth
name: Authenticate with Google Cloud
uses: google-github-actions/auth@v2
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@v3
with:
registry: ${{ secrets.ARTIFACT_REGISTRY }}
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}
- name: Setup api url
run: |
API_URL=$(gcloud run services list | grep api | awk '{print $4}')
echo "NEXT_PUBLIC_HOSTNAME=$API_URL/api" > app/web/.env.local
- name: build-tag-push
run: |
export GAR=${{ env.GAR }}
make build-push-web ${{ env.TAG }}
- name: Redeploy Cloudrun Service
run: |
gcloud run services update ${{ env.CR_SERVICE }} --region=${{ env.CR_REGION }} --image=${{ env.GAR }}web:${{ env.TAG }}