-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudbuild.cd.yaml
56 lines (50 loc) · 1.78 KB
/
cloudbuild.cd.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
# BE CAREFUL MODIFYING THIS FILE
# This has our continous delivery steps.
steps:
# This step runs the unit tests on the app
- id: Test
name: 'gcr.io/cloud-builders/go'
args: ['test','./...']
env: ['PROJECT_ROOT=github.com/expandorg/assignment']
# # This step builds the container image
- id: Build
name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/$PROJECT_ID/$_NAME:$SHORT_SHA', '.']
- id: BuildMigration
name: 'gcr.io/cloud-builders/docker'
args: ['build', '--tag=gcr.io/$PROJECT_ID/$_NAME-migration:$SHORT_SHA', 'migrations']
# This step pushes the image to Container Registry
- id: Push To Registry
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$_NAME:$SHORT_SHA']
- id: PushMigration
name: 'gcr.io/cloud-builders/docker'
args: ['push', 'gcr.io/$PROJECT_ID/$_NAME-migration:$SHORT_SHA']
# This step deploys the new version of our container image
# in the Kubernetes Engine cluster.
- id: Generate Kuberentes Manifest
name: 'gcr.io/cloud-builders/gcloud'
entrypoint: /bin/sh
args:
- '-c'
- |
sed "s/VERSION/${SHORT_SHA}/g;s/NAME/${_NAME}/g;s/MIGRATION/${_MIGRATION}/g;s/ORG/${PROJECT_ID}/g;s/ENV/${_ENV}/g;s/APP/${_APP}/g;s/DATA/${_DATA}/g" k8s.yaml > kubernetes.yaml
# Jobs image field is immutable, we delete and recreate it with new image.
- id: Delete Migration Job
name: 'gcr.io/cloud-builders/kubectl'
args:
- 'delete'
- 'job'
- '${_MIGRATION}'
env:
- CLOUDSDK_COMPUTE_ZONE=$_ZONE
- CLOUDSDK_CONTAINER_CLUSTER=$_CLUSTER
- id: Deploy
name: 'gcr.io/cloud-builders/kubectl'
args:
- 'apply'
- '-f'
- 'kubernetes.yaml'
env:
- CLOUDSDK_COMPUTE_ZONE=$_ZONE
- CLOUDSDK_CONTAINER_CLUSTER=$_CLUSTER