forked from DapperCollectives/CAST
-
Notifications
You must be signed in to change notification settings - Fork 2
97 lines (83 loc) · 3.02 KB
/
deploy-to-cloudrun-staging.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: "Deploy to Staging Cloud Run"
on:
push:
branches:
- staging
- jp/add-cloudrun-support
env:
# DB VARS
db_username: ${{ secrets.DB_USERNAME }}
db_password: ${{ secrets.DB_PASSWORD }}
db_hostname: ${{ secrets.DB_HOSTNAME }}
db_port: ${{ secrets.DB_PORT }}
db_name: ${{ secrets.DB_NAME }}
backend_api: ${{ secrets.BACKEND_API }}
tx_options: ${{ secrets.TX_OPTIONS }}
hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }}
sentry_url: ${{ secrets.SENTRY_STAGE_URL }}
# GCP VARS
BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }}
FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }}
GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }}
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }}
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }}
WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google auth
id: auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ env.SERVICE_ACCOUNT }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ env.PROJECT_ID }}
- name: Docker Auth
run: |-
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend
docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }}
- name: build and push frontend - stage -
env:
BACKEND: ${{ env.backend_api }}
run: |
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev
docker build -f ./frontend/Dockerfile.stage ./frontend -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }}
docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }}
deploy-staging-backend:
needs: [build]
environment: staging
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Google auth
id: auth
uses: google-github-actions/auth@v2
with:
token_format: 'access_token'
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }}
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }}
- name: Deploy Backend to Cloud Run
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ vars.BACKEND_GCP_SERVICE }}
image: ${{ env.BACKEND_DOCKER_IMAGE_URL }}
- name: Deploy Frontend to Cloud Run
uses: google-github-actions/deploy-cloudrun@v1
with:
service: ${{ vars.FRONTEND_GCP_SERVICE }}
image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }}