From 2471e25c2cfacdae6da5e9ccd65abe747d9ce5ff Mon Sep 17 00:00:00 2001 From: Ludovico Magnocavallo Date: Tue, 7 Feb 2023 10:04:03 +0100 Subject: [PATCH] post PR message on init or validate failure (#1135) --- .../templates/workflow-github.yaml | 12 ++++++++++++ .../templates/workflow-github.yaml | 12 ++++++++++++ .../0-bootstrap/templates/workflow-github.yaml | 18 +++++++++++++++++- .../1-resman/templates/workflow-github.yaml | 12 ++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/fast/stages-multitenant/0-bootstrap-tenant/templates/workflow-github.yaml b/fast/stages-multitenant/0-bootstrap-tenant/templates/workflow-github.yaml index 52325868..364ee8f4 100644 --- a/fast/stages-multitenant/0-bootstrap-tenant/templates/workflow-github.yaml +++ b/fast/stages-multitenant/0-bootstrap-tenant/templates/workflow-github.yaml @@ -92,11 +92,13 @@ jobs: # run Terraform init/validate/plan - id: tf-init name: Terraform init + continue-on-error: true run: | terraform init -no-color - id: tf-validate name: Terraform validate + continue-on-error: true run: terraform validate -no-color - id: tf-plan @@ -179,6 +181,16 @@ jobs: body: output }) + - id: check-init + name: Check init failure + if: steps.tf-init.outcome != 'success' + run: exit 1 + + - id: check-validate + name: Check validate failure + if: steps.tf-validate.outcome != 'success' + run: exit 1 + - id: check-plan name: Check plan failure if: steps.tf-plan.outcome != 'success' diff --git a/fast/stages-multitenant/1-resman-tenant/templates/workflow-github.yaml b/fast/stages-multitenant/1-resman-tenant/templates/workflow-github.yaml index 8a946d84..e9669909 100644 --- a/fast/stages-multitenant/1-resman-tenant/templates/workflow-github.yaml +++ b/fast/stages-multitenant/1-resman-tenant/templates/workflow-github.yaml @@ -88,11 +88,13 @@ jobs: # run Terraform init/validate/plan - id: tf-init name: Terraform init + continue-on-error: true run: | terraform init -no-color - id: tf-validate name: Terraform validate + continue-on-error: true run: terraform validate -no-color - id: tf-plan @@ -175,6 +177,16 @@ jobs: body: output }) + - id: check-init + name: Check init failure + if: steps.tf-init.outcome != 'success' + run: exit 1 + + - id: check-validate + name: Check validate failure + if: steps.tf-validate.outcome != 'success' + run: exit 1 + - id: check-plan name: Check plan failure if: steps.tf-plan.outcome != 'success' diff --git a/fast/stages/0-bootstrap/templates/workflow-github.yaml b/fast/stages/0-bootstrap/templates/workflow-github.yaml index 8a946d84..87b5ae1a 100644 --- a/fast/stages/0-bootstrap/templates/workflow-github.yaml +++ b/fast/stages/0-bootstrap/templates/workflow-github.yaml @@ -29,7 +29,9 @@ env: FAST_WIF_PROVIDER: ${identity_provider} SSH_AUTH_SOCK: /tmp/ssh_agent.sock TF_PROVIDERS_FILE: ${tf_providers_file} - TF_VAR_FILES: ${tf_var_files == [] ? "''" : join("\n ", tf_var_files)} + %{~ if tf_var_files != [] ~} + TF_VAR_FILES: ${join("\n ", tf_var_files)} + %{~ endif ~} TF_VERSION: 1.3.2 jobs: @@ -73,11 +75,13 @@ jobs: run: | gcloud alpha storage cp -r \ "gs://$${{env.FAST_OUTPUTS_BUCKET}}/providers/$${{env.TF_PROVIDERS_FILE}}" ./ + %{~ if tf_var_files != [] ~} gcloud alpha storage cp -r \ "gs://$${{env.FAST_OUTPUTS_BUCKET}}/tfvars" ./ for f in $${{env.TF_VAR_FILES}}; do ln -s "tfvars/$f" ./ done + %{~ endif ~} - id: tf-setup name: Set up Terraform @@ -88,10 +92,12 @@ jobs: # run Terraform init/validate/plan - id: tf-init name: Terraform init + continue-on-error: true run: | terraform init -no-color - id: tf-validate + continue-on-error: true name: Terraform validate run: terraform validate -no-color @@ -175,6 +181,16 @@ jobs: body: output }) + - id: check-init + name: Check init failure + if: steps.tf-init.outcome != 'success' + run: exit 1 + + - id: check-validate + name: Check validate failure + if: steps.tf-validate.outcome != 'success' + run: exit 1 + - id: check-plan name: Check plan failure if: steps.tf-plan.outcome != 'success' diff --git a/fast/stages/1-resman/templates/workflow-github.yaml b/fast/stages/1-resman/templates/workflow-github.yaml index 8a946d84..41c51411 100644 --- a/fast/stages/1-resman/templates/workflow-github.yaml +++ b/fast/stages/1-resman/templates/workflow-github.yaml @@ -88,10 +88,12 @@ jobs: # run Terraform init/validate/plan - id: tf-init name: Terraform init + continue-on-error: true run: | terraform init -no-color - id: tf-validate + continue-on-error: true name: Terraform validate run: terraform validate -no-color @@ -175,6 +177,16 @@ jobs: body: output }) + - id: check-init + name: Check init failure + if: steps.tf-init.outcome != 'success' + run: exit 1 + + - id: check-validate + name: Check validate failure + if: steps.tf-validate.outcome != 'success' + run: exit 1 + - id: check-plan name: Check plan failure if: steps.tf-plan.outcome != 'success'