-
Notifications
You must be signed in to change notification settings - Fork 4
/
cloudbuild.yaml
78 lines (65 loc) · 1.88 KB
/
cloudbuild.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
67
68
69
70
71
72
73
74
75
76
77
78
# https://cloud.google.com/build/docs/configuring-builds/substitute-variable-values
steps:
- id: build-api
name: docker
args:
- build
- '--no-cache'
- '-t'
- $_IMAGE_NAME
- .
- id: push
name: docker
args:
- push
- $_IMAGE_NAME
# https://cloud.google.com/build/docs/configuring-builds/pass-data-between-steps
- id: add-config
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
entrypoint: bash
args:
- '-c'
- |
gcloud secrets versions access latest --secret=${_VSCHEDULERC_KEY} \
> /workspace/.vschedulerc.toml
# https://cloud.google.com/sql/docs/mysql/connect-build#connect_to
- id: migration
name: $_IMAGE_NAME
secretEnv: ['DATABASE_URL']
entrypoint: bash
dir: /app
args:
- '-c'
- |
cp /workspace/.vschedulerc.toml .vschedulerc.toml
wget https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 --quiet -O \
cloud_sql_proxy
chmod +x cloud_sql_proxy
mkdir /cloudsql
./cloud_sql_proxy -instances=${_SQL_CONNECTION_NAME} -dir=/cloudsql \
& sleep 2;
echo /cloudsql/${_SQL_CONNECTION_NAME}
ls -al /cloudsql/${_SQL_CONNECTION_NAME}
yarn workspace @neet/vschedule-api run prisma migrate deploy
yarn workspace @neet/vschedule-api run prisma db seed
- id: deploy
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
entrypoint: gcloud
args:
- run
- services
- update
- $_SERVICE_NAME
- '--platform=managed'
- '--image=$_IMAGE_NAME'
- '--region=$_DEPLOY_REGION'
- '--quiet'
images:
- $_IMAGE_NAME
options:
substitutionOption: ALLOW_LOOSE
dynamicSubstitutions: true
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/${_DATABASE_URL_KEY}/versions/latest
env: DATABASE_URL