-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcloudbuild.yaml
154 lines (152 loc) · 4.77 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# steps:
# - name: gcr.io/k8s-skaffold/pack
# env:
# - GOOGLE_ENTRYPOINT=$_ENTRYPOINT
# args:
# - build
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# - '--builder=gcr.io/buildpacks/builder:v1'
# - '--path=.'
# - '--env=GOOGLE_ENTRYPOINT'
# id: Buildpack
# entrypoint: pack
# - name: gcr.io/cloud-builders/docker
# args:
# - push
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# id: Push
# - name: gcr.io/google.com/cloudsdktool/cloud-sdk
# args:
# - run
# - services
# - update
# - $_SERVICE_NAME
# - '--platform=managed'
# - '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# - >-
# --labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS
# - '--region=$_DEPLOY_REGION'
# - '--quiet'
# id: Deploy
# entrypoint: gcloud
# images:
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# options:
# substitutionOption: ALLOW_LOOSE
# substitutions:
# _SERVICE_NAME: continuous-deployment
# _ENTRYPOINT: node src/server.ts
# _DEPLOY_REGION: europe-west1
# _GCR_HOSTNAME: eu.gcr.io
# _LABELS: gcb-trigger-id=a7b3a63f-7716-4957-8f16-cb2b612ecce3
# _TRIGGER_ID: a7b3a63f-7716-4957-8f16-cb2b612ecce3
# _PLATFORM: managed
# tags:
# - gcp-cloud-build-deploy-cloud-run
# - gcp-cloud-build-deploy-cloud-run-managed
# - continuous-deployment
# steps:
# - name: gcr.io/k8s-skaffold/pack
# env:
# - GOOGLE_ENTRYPOINT=$_ENTRYPOINT
# args:
# - build
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# - '--builder=gcr.io/buildpacks/builder:v1'
# - '--path=.'
# - '--env=GOOGLE_ENTRYPOINT'
# id: Buildpack
# entrypoint: pack
# - name: 'gcr.io/cloud-builders/npm'
# args: ['install']
# - name: 'gcr.io/cloud-builders/npm'
# args: ['run', 'init-env']
# env:
# - TEST_ENV=$_TEST_ENV
# - CDN_CLOUD_NAME=$_CDN_CLOUD_NAME
# - CDN_API_KEY=$_CDN_API_KEY
# - CDN_API_SECRET=$_CDN_API_SECRET
# - MONGO_URI=$_MONGO_URI
# - name: 'gcr.io/cloud-builders/npm'
# args: ['run', 'build']
# - name: gcr.io/cloud-builders/docker
# args:
# - push
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# id: Push
# - name: 'gcr.io/cloud-builders/gcloud'
# args: ['app', 'deploy']
# images:
# - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
# options:
# substitutionOption: ALLOW_LOOSE
# substitutions:
# _SERVICE_NAME: continuous-deployment
# _ENTRYPOINT: node src/server.ts
# _DEPLOY_REGION: europe-west1
# _GCR_HOSTNAME: eu.gcr.io
# _LABELS: gcb-trigger-id=a7b3a63f-7716-4957-8f16-cb2b612ecce3
# _TRIGGER_ID: a7b3a63f-7716-4957-8f16-cb2b612ecce3
# _PLATFORM: managed
# tags:
# - gcp-cloud-build-deploy-cloud-run
# - gcp-cloud-build-deploy-cloud-run-managed
# - continuous-deployment
steps:
# build the container image
- name: 'gcr.io/cloud-builders/docker'
args:
- 'build'
- '--build-arg'
- '_CDN_CLOUD_NAME=$_CDN_CLOUD_NAME'
- '--build-arg'
- '_CDN_API_KEY=$_CDN_API_KEY'
- '--build-arg'
- '_CDN_API_SECRET=$_CDN_API_SECRET'
- '--build-arg'
- '_JWT_KEY=$_JWT_KEY'
- '--build-arg'
- '_MONGO_URI=$_MONGO_URI'
- '-t'
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- '.'
id: Build
# push the container image to Container Registry
- name: gcr.io/cloud-builders/docker
args:
- push
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
id: Push
# deploy container image to Cloud Run
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
args:
- run
- services
- update
- $_SERVICE_NAME
- '--platform=managed'
- '--image=$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
- >-
--labels=managed-by=gcp-cloud-build-deploy-cloud-run,commit-sha=$COMMIT_SHA,gcb-build-id=$BUILD_ID,gcb-trigger-id=$_TRIGGER_ID,$_LABELS
- '--region=$_DEPLOY_REGION'
- '--quiet'
id: Deploy
entrypoint: gcloud
env:
- PORT=8080
images:
- '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'
options:
substitutionOption: ALLOW_LOOSE
substitutions:
_SERVICE_NAME: continuous-deployment
_ENTRYPOINT: node src/server.ts
_DEPLOY_REGION: europe-west1
_GCR_HOSTNAME: eu.gcr.io
_LABELS: gcb-trigger-id=a7b3a63f-7716-4957-8f16-cb2b612ecce3
_TRIGGER_ID: a7b3a63f-7716-4957-8f16-cb2b612ecce3
_PLATFORM: managed
tags:
- gcp-cloud-build-deploy-cloud-run
- gcp-cloud-build-deploy-cloud-run-managed
- continuous-deployment