From 65af83dfb38563e54885835ce436c09e870481b6 Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Tue, 2 Jul 2024 22:42:17 +0200 Subject: [PATCH] make sure Terraform E2E test fails on detected changes --- .github/workflows/test.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f063e9..bcaa33f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,9 +49,12 @@ jobs: BETTERUPTIME_API_TOKEN: ${{ secrets.UPTIME_E2E_TEAM_TOKEN }} - name: Plan resources via Terraform - must be empty run: | - make terraform CONFIGURATION="${{ matrix.config }}" ARGS="plan --detailed-exitcode --input=false" - if [ $? -eq 2 ]; then - echo "Terraform plan has changes, exiting with error." + make terraform CONFIGURATION="${{ matrix.config }}" ARGS="plan --input=false --out=tfplan" + CHANGES="$(terraform -chdir="examples/advanced" show --json tfplan | jq '.resource_changes | length')" + if [ "$CHANGES" == "0" ]; then + echo "No planned changes detected after first apply. Success!" + else + echo "$CHANGES planned changes detected after first apply. Failure!" exit 1 fi env: