@@ -136,9 +136,100 @@ jobs:
136
136
tags : ${{ steps.meta.outputs.tags }}
137
137
138
138
deploy-pre-release :
139
+ strategy :
140
+ fail-fast : false
141
+ matrix :
142
+ environment : [ pre-release-preview ]
143
+ include :
144
+ - environment : pre-release-preview
145
+ environment_prefix : pre-release
146
+ cardano_network : preview
147
+ mithril_api_domain : api.mithril.network
148
+ mithril_protocol_parameters : |
149
+ {
150
+ k = 5
151
+ m = 100
152
+ phi_f = 0.65
153
+ }
154
+ mithril_signers : |
155
+ {
156
+ "1" = {
157
+ pool_id = "pool18r62tz408lkgfu6pq5svwzkh2vslkeg6mf72qf3h8njgvzhx9ce",
158
+ },
159
+ }
160
+ terraform_backend_bucket : hydra-terraform-admin
161
+ google_region : europe-west1
162
+ google_zone : europe-west1-b
163
+ google_machine_type : e2-medium
164
+
139
165
runs-on : ubuntu-22.04
166
+
140
167
needs :
141
168
- build-push-docker
169
+
170
+ environment : ${{ matrix.environment }}
171
+
172
+ env :
173
+ GOOGLE_APPLICATION_CREDENTIALS : ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }}
174
+ GENESIS_SECRET_KEY : ${{ secrets.GENESIS_SECRET_KEY }}
175
+ GENESIS_VERIFICATION_KEY_URL : ${{ secrets.GENESIS_VERIFICATION_KEY_URL }}
176
+ DOCKER_IMAGE_ID : pre-release
177
+
178
+ defaults :
179
+ run :
180
+ working-directory : mithril-infra
181
+
142
182
steps :
143
- - name : TODO
144
- run : echo "Add terraform deployment to a pre-release environment here"
183
+
184
+ - name : Checkout sources
185
+ uses : actions/checkout@v3
186
+
187
+ - name : Prepare service account credentials
188
+ run : |
189
+ echo '${{ env.GOOGLE_APPLICATION_CREDENTIALS}}' > ./google-application-credentials.json
190
+ chmod u+x ./assets/tools/google-credentials-public-key.sh
191
+ ./assets/tools/google-credentials-public-key.sh ./google-application-credentials.json ./assets/ssh_keys curry
192
+
193
+ - name : Prepare terraform variables
194
+ run : |
195
+ cat > ./env.variables.tfvars << EOF
196
+ environment_prefix = "${{ matrix.environment_prefix }}"
197
+ cardano_network = "${{ matrix.cardano_network }}"
198
+ google_region = "${{ matrix.google_region }}"
199
+ google_zone = "${{ matrix.google_zone }}"
200
+ google_machine_type = "${{ matrix.google_machine_type }}"
201
+ google_service_credentials_json_file = "./google-application-credentials.json"
202
+ mithril_api_domain = "${{ matrix.mithril_api_domain }}"
203
+ mithril_image_id = "${{ env.DOCKER_IMAGE_ID }}"
204
+ mithril_genesis_verification_key_url = "${{ env.GENESIS_VERIFICATION_KEY_URL }}"
205
+ mithril_genesis_secret_key = "${{ env.GENESIS_SECRET_KEY }}"
206
+ mithril_protocol_parameters = ${{ matrix.mithril_protocol_parameters }}
207
+ mithril_signers = ${{ matrix.mithril_signers }}
208
+ EOF
209
+ terraform fmt ./env.variables.tfvars
210
+ cat ./env.variables.tfvars
211
+
212
+ - name : Setup Terraform
213
+ uses : hashicorp/setup-terraform@v2
214
+ with :
215
+ terraform_wrapper : false
216
+
217
+ - name : Init Terraform
218
+ run : |
219
+ GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform init -backend-config="bucket=${{ matrix.terraform_backend_bucket }}" -backend-config="prefix=terraform/mithril-${{ matrix.environment }}"
220
+
221
+ - name : Check Terraform
222
+ run : terraform fmt -check
223
+
224
+ - name : Terraform Plan
225
+ run : |
226
+ GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform plan --var-file=./env.variables.tfvars
227
+
228
+ - name : Terraform Apply
229
+ run : |
230
+ GOOGLE_APPLICATION_CREDENTIALS=./google-application-credentials.json terraform apply -auto-approve --var-file=./env.variables.tfvars
231
+
232
+ - name : Cleanup
233
+ run : |
234
+ rm -f ./env.variables.tfvars
235
+ rm -f ./google-application-credentials.json
0 commit comments