-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
66 lines (66 loc) · 2.55 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,LOGIN_BASE_URI=$_LOGIN_BASE_URI,META_GRAPH_API_BASE_URI=$_META_GRAPH_API_BASE_URI,META_FB_PAGE_ID=$_META_FB_PAGE_ID,META_FB_VRFY_TOKEN=$_META_FB_VRFY_TOKEN,FPI_APP_TO_APP_USERN=$_FPI_APP_TO_APP_USERN,USER_BASE_URI=$_USER_BASE_URI
- >-
--set-secrets=MONGO_CONN_STRING=vbl_mongo_connection_string:latest,OIDC_SECRET=oidc_secret_keycloak:latest,META_FB_APP_SECRET=meta_fb_app_secret:latest,META_FB_PAGE_ACCESS_TOKEN=meta_fb_page_access_token:latest,FPI_APP_TO_APP_PASSW=fpi_bot_api_creds_secret_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"