-
Notifications
You must be signed in to change notification settings - Fork 1
/
.drone.yml
189 lines (184 loc) · 5.13 KB
/
.drone.yml
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
kind: pipeline
name: terraform-google-astronomer-cloud
steps:
- name: lint
image: hashicorp/terraform:0.12.26
commands:
- cp providers.tf.example providers.tf
- terraform init
- terraform fmt -check=true
- |
echo '{
"type": "service_account",
"project_id": "[PROJECT-ID]",
"private_key_id": "[KEY-ID]",
"private_key": "-----BEGIN PRIVATE KEY-----\n[PRIVATE-KEY]\n-----END PRIVATE KEY-----\n",
"client_email": "[SERVICE-ACCOUNT-EMAIL]",
"client_id": "[CLIENT-ID]",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/[SERVICE-ACCOUNT-EMAIL]"
}' > ~/account.json
- terraform validate -var "deployment_id=validate" -var "dns_managed_zone=validate-fake.com" -var "[email protected]" -var "astronomer_helm_values=''"
- rm -rf .terraform
- |
for example in $(find examples -maxdepth 1 -mindepth 1 -type d); do
cp providers.tf.example $example/providers.tf
cd $example
echo $example
terraform init
terraform fmt -check=true
terraform validate -var "deployment_id=citest" -var "dns_managed_zone=steven-zone" -var "astronomer_helm_values=''"
rm providers.tf
rm -rf .terraform
cd -
done
- terraform -v
- rm providers.tf
- rm ~/account.json
when:
event:
- pull_request
- push
# - name: from_scratch
# image: sjmiller609/helm-kubectl-terraform:latest
# environment:
# GOOGLE_CREDENTIAL_FILE_CONTENT:
# from_secret: GOOGLE_CREDENTIAL_FILE_CONTENT
# commands:
# - EXAMPLE=from_scratch pipeline/run_terraform.sh
# when:
# event:
# - push
# branch:
# - master
#
# # TODO: expand testing
# - name: system_test
# image: sjmiller609/helm-kubectl-terraform:latest
# environment:
# GOOGLE_CREDENTIAL_FILE_CONTENT:
# from_secret: GOOGLE_CREDENTIAL_FILE_CONTENT
# commands:
# - EXAMPLE=from_scratch pipeline/run_test.sh
# when:
# event:
# - push
# branch:
# - master
#
# - name: from_scratch_cleanup
# image: sjmiller609/helm-kubectl-terraform:latest
# environment:
# GOOGLE_CREDENTIAL_FILE_CONTENT:
# from_secret: GOOGLE_CREDENTIAL_FILE_CONTENT
# commands:
# - DESTROY=1 EXAMPLE=from_scratch pipeline/run_terraform.sh
# when:
# event:
# - push
# status:
# - failure
# - success
# branch:
# - master
#
# # It helps to try the cleanup again if it fails
# # for some reason the first time.
# # A tagged release will not happen if the destroy
# # fails the first time.
# - name: wait_then_try_cleanup_again
# image: sjmiller609/helm-kubectl-terraform:latest
# environment:
# GOOGLE_CREDENTIAL_FILE_CONTENT:
# from_secret: GOOGLE_CREDENTIAL_FILE_CONTENT
# commands:
# - echo 'sleeping 10 minutes'
# - sleep 600
# - DESTROY=1 EXAMPLE=from_scratch pipeline/run_terraform.sh
# when:
# event:
# - push
# branch:
# - master
# status:
# - failure
- name: git_tag
image: docker:git
environment:
DEPLOY_KEY:
from_secret: DEPLOY_KEY
commands:
- eval `ssh-agent`
- echo "$DEPLOY_KEY" | ssh-add -
- TAG=0.2.${DRONE_BUILD_NUMBER}
- git tag $TAG
- mkdir -p $HOME/.ssh
- ssh-keyscan -t rsa github.com >> $HOME/.ssh/known_hosts
- git push $DRONE_GIT_SSH_URL $DRONE_BRANCH --tags || true
when:
event:
- push
status:
- success
branch:
- master
repo:
- astronomer/terraform-google-astronomer-cloud
- name: notify_build_success
image: plugins/slack
settings:
webhook:
from_secret: WEBHOOK_URL
channel: ci-debug
username: terraform-ci
template: >
{{repo.name}}
{{build.link}}
{{#success build.status}}
succeeded
{{else}}
failed
{{/success}}
when:
event:
- push
status:
- success
- failure
branch:
- master
repo:
- astronomer/terraform-google-astronomer-cloud
- name: notify_tag
image: plugins/slack
settings:
webhook:
from_secret: WEBHOOK_URL
channel: ci-debug
username: terraform-ci
template: >
{{repo.name}}
version {{build.tag}} released
when:
event:
- tag
status:
- success
repo:
- astronomer/terraform-google-astronomer-cloud
# - name: update_google_environment
# image: docker:git
# environment:
# DEPLOY_KEY:
# from_secret: DEPLOY_KEY_ENVIRONMENTS
# commands:
# - pipeline/update_stage_environment.sh
# when:
# event:
# - tag
# status:
# - success
# repo:
# - astronomer/terraform-google-astronomer-cloud