-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathcloudbuild.yaml
More file actions
52 lines (46 loc) · 1.4 KB
/
cloudbuild.yaml
File metadata and controls
52 lines (46 loc) · 1.4 KB
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
# GCP only cloudbuild script to build container image and deploy to Cloud Run Serverless
substitutions:
_SERVICE:
_REGION:
_SECRET_NAME:
_PORT:
_PLATFORM:
_CLUSTER_NAME:
_CLUSTER_LOCATION:
steps:
- id: 'Pull env file from Secrets Manager'
name: gcr.io/cloud-builders/gcloud
entrypoint: 'bash'
args: [ '-c', "gcloud secrets versions access latest --secret=${_SECRET_NAME} --format='get(payload.data)' | tr '_-' '/+' | base64 -d > .env" ]
- id: 'Build Container Image'
name: 'registry.hub.docker.com/library/docker:18'
args: [
'build',
'--tag', 'gcr.io/${PROJECT_ID}/github.com/path-check/${_SERVICE}:$BRANCH_NAME-$SHORT_SHA',
'.' ]
- id: 'Publish Container'
name: 'registry.hub.docker.com/library/docker:18'
args: [
'push',
'gcr.io/${PROJECT_ID}/github.com/path-check/${_SERVICE}:$BRANCH_NAME-$SHORT_SHA',
]
#
# Deploys a Cloud Run service.
#
- id: 'Deploy to Cloud Run'
name: 'gcr.io/google.com/cloudsdktool/cloud-sdk:293.0.0-alpine'
args:
- 'bash'
- '-eEuo'
- 'pipefail'
- '-c'
- |-
gcloud run deploy "${_SERVICE}-${BRANCH_NAME}" \
--quiet \
--project "${PROJECT_ID}" \
--platform "${_PLATFORM}" \
--namespace "${_NAMESPACE}" \
--port "${_PORT}" \
--cluster "${_CLUSTER_NAME}" \
--cluster-location "${_CLUSTER_LOCATION}" \
--image "gcr.io/${PROJECT_ID}/github.com/path-check/${_SERVICE}:$BRANCH_NAME-$SHORT_SHA"