diff --git a/.github/workflows/reusable_terraform_plan_apply.yml b/.github/workflows/reusable_terraform_plan_apply.yml index 72f0fe4de..cbe19bc28 100644 --- a/.github/workflows/reusable_terraform_plan_apply.yml +++ b/.github/workflows/reusable_terraform_plan_apply.yml @@ -144,7 +144,7 @@ jobs: id: get_destroy_count env: DESTROY_THRESHOLD: ${{ env.TF_DESTROY_THRESHOLD }} - PLAN_SUMMARY: ${{ steps.show.outputs.plan_summary }} + PLAN_DESTROY_CHECK: ${{ steps.show.outputs.plan_destroy_check }} run: | bash scripts/get-terraform-destroy-count.sh diff --git a/scripts/get-terraform-destroy-count.sh b/scripts/get-terraform-destroy-count.sh index 87fc0a64d..705e22c54 100644 --- a/scripts/get-terraform-destroy-count.sh +++ b/scripts/get-terraform-destroy-count.sh @@ -8,17 +8,17 @@ set -e # It also runs some checks to ensure that the values for the count and the threshold are valid. # Checks that PLAN_SUMMARY is set. Without this the script will fail so we force an exit. -if [ -z "$PLAN_SUMMARY" ]; then - echo "PLAN_SUMMARY is not set" +if [ -z "$PLAN_DESTROY_CHECK" ]; then + echo "PLAN_DESTROY_CHECK is not set" exit 1 fi -destroy_count=$(echo "$PLAN_SUMMARY" | grep -oE 'Plan: [0-9]+ to add, [0-9]+ to change, [0-9]+ to destroy.' | awk '{print $8}') +destroy_count=$(echo "$PLAN_DESTROY_CHECK" | grep -oE 'Plan: [0-9]+ to add, [0-9]+ to change, [0-9]+ to destroy.' | awk '{print $8}') echo "destroy_threshold=$DESTROY_THRESHOLD" echo "destroy_count=$destroy_count" -if echo "$PLAN_SUMMARY" | grep -q "No changes. Your infrastructure matches the configuration."; then +if echo "$PLAN_DESTROY_CHECK" | grep -q "No changes. Your infrastructure matches the configuration."; then echo "No changes. Your infrastructure matches the configuration." destroy_count=0 exit 0 diff --git a/scripts/terraform-plan.sh b/scripts/terraform-plan.sh index 0b54a76ae..4c5621bfa 100755 --- a/scripts/terraform-plan.sh +++ b/scripts/terraform-plan.sh @@ -38,6 +38,8 @@ else echo "$plan_output" # Output full redacted plan to stdout (GitHub Actions logs) fi -echo "plan_summary=$plan_summary" >> "$GITHUB_OUTPUT" +echo "plan_destroy_check=$plan_summary" >> "$GITHUB_OUTPUT" + echo "summary<> $GITHUB_OUTPUT +echo "$plan_summary" >> $GITHUB_OUTPUT echo "EOF" >> $GITHUB_OUTPUT