-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.yaml
66 lines (66 loc) · 2.45 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
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args:
- -c
- |
on_going_build=($(gcloud builds list --ongoing --format='value(id)' --filter="substitutions._TRIGGER_ID=$_TRIGGER_ID" | xargs))
for (( i=0; i<${#on_going_build[@]}; i++ )); do
if [ "$i" -gt "0" ]; then # skip current
echo "Cancelling build ${on_going_build[i]}"
gcloud builds cancel --no-user-output-enabled ${on_going_build[i]}
fi
done
id: "Cancel ongoing builds"
entrypoint: 'bash'
- name: gcr.io/cloud-builders/docker
args:
- build
- '--no-cache'
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '--build-arg=GITHUB_USERNAME=$_GITHUB_USERNAME'
- '--build-arg=GITHUB_TOKEN=$_GITHUB_TOKEN'
- .
- '-f'
- Dockerfile
id: "Build docker image"
- name: gcr.io/cloud-builders/docker
args:
- push
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
id: "Push to registry"
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
args:
- run
- services
- update
- $_SERVICE_NAME
- '--platform=managed'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- >-
--set-env-vars=OIDC_CLIENT_ID=$_OIDC_CLIENT_ID,OIDC_AUTH_URL=$_OIDC_AUTH_URL,SMS_API_KEY=$_SMS_API_KEY,SMS_SID=$_SMS_SID,M360_BROADCAST_URL=$_M360_BROADCAST_URL
- >-
--set-secrets=MONGO_CONN_STRING=vbl_mongo_connection_string:latest,OIDC_SECRET=oidc_secret_keycloak:latest,SMS_SECRET=m360_secret_api_key:latest,FPI_MO_WEBHOOK_KEY=fpi_mo_incoming_webook_key:latest,FPI_DLR_WEBHOOK_KEY=fpi_dlr_incoming_webhook_key:latest,FPI_GEN_WEBHOOK_KEY=fpi_gen_incoming_webhook_key:latest
- >-
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS
- '--cpu=1000m'
- '--memory=384Mi'
- '--region=$_DEPLOY_REGION'
- '--quiet'
id: "Deploy to cloud run"
entrypoint: gcloud
- name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:slim'
args:
- run
- services
- add-iam-policy-binding
- $_SERVICE_NAME
- '--member=allUsers'
- '--role=roles/run.invoker'
- '--region=$_DEPLOY_REGION'
id: "Configure cloud run"
entrypoint: gcloud
options:
machineType: E2_HIGHCPU_8
substitutionOption: ALLOW_LOOSE
timeout: "7200s"