/
cloudbuild.yaml
72 lines (66 loc) · 2.42 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
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
options:
env:
- 'BRANCH_NAME=$BRANCH_NAME'
- 'EXAMPLE_BUILD=web_app_protection_example'
- 'STATE_BUCKET_NAME=$_STATE_BUCKET_NAME'
substitutions:
_BEFORE_SCRIPT: |
echo "Adding bucket information to backends"
for i in `find -name 'backend.tf'`; do sed -r -i "s/_BUCKET_GCS_/"$STATE_BUCKET_NAME"/" $i; done
for i in `find -name 'pipeline-functions.sh'`;do chmod +x $i; done
cd examples/"$EXAMPLE_BUILD" ; cp -Prf ../../modules .
for i in `find environments/ -mindepth 1 -maxdepth 1 -type d` ; do cp -Prf *.tf ./scripts/ $i ; done
steps:
- name: 'gcr.io/cloud-foundation-cicd/cft/developer-tools-light:1'
entrypoint: '/bin/bash'
id: 'tf_init'
args:
- '-c'
- |
if [[ "$$BRANCH_NAME" == "dev" || "$$BRANCH_NAME" == "prd" || "$$BRANCH_NAME" == "npd" ]]; then
$_BEFORE_SCRIPT
build/pipeline-functions.sh init "$$BRANCH_NAME"
fi
- name: 'gcr.io/cloud-foundation-cicd/cft/developer-tools-light:1'
entrypoint: '/bin/bash'
id: 'tf_plan_all'
args:
- '-c'
- |
if [[ "$$BRANCH_NAME" != "dev" && "$$BRANCH_NAME" != "prd" && "$$BRANCH_NAME" != "npd" ]]; then
$_BEFORE_SCRIPT
build/pipeline-functions.sh plan_validate_all "$$BRANCH_NAME"
fi
- name: 'gcr.io/cloud-foundation-cicd/cft/developer-tools-light:1'
entrypoint: '/bin/bash'
id: 'tf_plan'
args:
- '-c'
- |
if [[ "$$BRANCH_NAME" == "dev" || "$$BRANCH_NAME" == "prd" || "$$BRANCH_NAME" == "npd" ]]; then
$_BEFORE_SCRIPT
build/pipeline-functions.sh plan "$$BRANCH_NAME"
fi
- name: 'gcr.io/cloud-foundation-cicd/cft/developer-tools-light:1'
entrypoint: '/bin/bash'
id: 'tf_apply'
args:
- '-c'
- |
if [[ "$$BRANCH_NAME" == "dev" || "$$BRANCH_NAME" == "prd" || "$$BRANCH_NAME" == "npd" ]]; then
$_BEFORE_SCRIPT
build/pipeline-functions.sh apply "$$BRANCH_NAME"
fi