-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcloudbuild.meta.yaml
82 lines (77 loc) · 2.34 KB
/
cloudbuild.meta.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
steps:
- id: 'branch name'
name: 'alpine'
entrypoint: 'sh'
args:
- '-c'
- |
echo "***********************"
echo "$BRANCH_NAME"
echo "***********************"
# - id: 'build app'
# name: 'gcr.io/cloud-builders/gcloud'
# args: ['builds', 'submit', '.', '--config cloudbuild.app.yaml']
# waitFor: ['-'] # start in parallel
- id: 'build api'
name: 'gcr.io/cloud-builders/gcloud'
args: ['builds', 'submit', '.', '--config cloudbuild.api.yaml']
waitFor: ['-'] # start in parallel
- id: 'tf init'
name: 'hashicorp/terraform:1.0.0'
entrypoint: 'sh'
args:
- '-c'
- |
cd infrastructure
for workspace in $(terraform workspace list | sed -e 's/*//g' -e 's/ //g')
do
echo "*************** TERRAFORM INIT ******************"
echo "******* Switching to workspace: ${workspace} ********"
echo "*************************************************"
terraform workspace select ${workspace} || exit 1
terraform init || exit 1
done
# [START tf-plan]
# - id: 'tf plan'
# name: 'hashicorp/terraform:1.0.0'
# entrypoint: 'sh'
# args:
# - '-c'
# - |
# if [ -d "environments/$BRANCH_NAME/" ]; then
# cd environments/$BRANCH_NAME
# echo pwd
# # terraform plan
# else
# for dir in environments/*/
# do
# cd ${dir}
# echo pwd
# # env=${dir%*/}
# # env=${env#*/}
# # echo ""
# # echo "*************** TERRAFOM PLAN ******************"
# # echo "******* At environment: ${env} ********"
# # echo "*************************************************"
# # terraform plan || exit 1
# # cd ../../
# done
# fi
# [END tf-plan]
# [START tf-apply]
# - id: 'tf apply'
# name: 'hashicorp/terraform:1.0.0'
# entrypoint: 'sh'
# args:
# - '-c'
# - |
# if [ -d "environments/$BRANCH_NAME/" ]; then
# cd environments/$BRANCH_NAME
# echo pwd
# # terraform apply -auto-approve
# else
# echo "***************************** SKIPPING APPLYING *******************************"
# echo "Branch '$BRANCH_NAME' does not represent an official environment."
# echo "*******************************************************************************"
# fi
# [END tf-apply]