-
Notifications
You must be signed in to change notification settings - Fork 3
/
cloudbuild.yaml
61 lines (55 loc) · 1.6 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
# [START cloudbuild]
steps:
# This step builds the container image.
- name: 'gcr.io/cloud-builders/docker'
id: Build
args:
- 'build'
- '-t'
- 'gcr.io/$PROJECT_ID/sysrant:$SHORT_SHA'
- '.'
# This step pushes the image to Container Registry
# The PROJECT_ID and SHORT_SHA variables are automatically
# replaced by Cloud Build.
- name: 'gcr.io/cloud-builders/docker'
id: Push
args:
- 'push'
- 'gcr.io/$PROJECT_ID/sysrant:$SHORT_SHA'
# [END cloudbuild]
# [START cloudbuild-trigger-cd]
# This step clones the sysrant-env repository
- name: 'gcr.io/cloud-builders/gcloud'
id: Clone env repository
entrypoint: /bin/sh
args:
- '-c'
- |
gcloud source repos clone sysrant-env && \
cd sysrant-env && \
git checkout candidate && \
git config user.email $(gcloud auth list --filter=status:ACTIVE --format='value(account)')
# This step generates the new manifest
- name: 'gcr.io/cloud-builders/gcloud'
id: Generate manifest
entrypoint: /bin/sh
args:
- '-c'
- |
sed "s/GOOGLE_CLOUD_PROJECT/${PROJECT_ID}/g" kubernetes.yaml.tpl | \
sed "s/COMMIT_SHA/${SHORT_SHA}/g" > sysrant-env/kubernetes.yaml
# This step pushes the manifest back to sysrant-env
- name: 'gcr.io/cloud-builders/gcloud'
id: Push manifest
entrypoint: /bin/sh
args:
- '-c'
- |
set -x && \
cd sysrant-env && \
git add kubernetes.yaml && \
git commit -m "Deploying image gcr.io/${PROJECT_ID}/sysrant:${SHORT_SHA}
Built from commit ${COMMIT_SHA} of repository sysrant-app
Author: $(git log --format='%an <%ae>' -n 1 HEAD)" && \
git push origin candidate
# [END cloudbuild-trigger-cd]