diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 638ea52..6387991 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -219,6 +219,42 @@ jobs: echo "TEST remote state access verified." + # Preview infrastructure changes without applying them. + - name: Plan TEST infrastructure + shell: bash + env: + TF_IN_AUTOMATION: "true" + run: | + set -euo pipefail + + for STACK in network frontend; do + echo "::group::TEST $STACK plan" + + set +e + tofu -chdir="environments/test/$STACK" plan \ + -input=false \ + -no-color \ + -lock-timeout=5m \ + -detailed-exitcode + EXIT_CODE=$? + set -e + + case "$EXIT_CODE" in + 0) + echo "TEST $STACK: No changes required." + ;; + 2) + echo "::warning::TEST $STACK: Infrastructure changes detected. Review the plan." + ;; + *) + echo "::error::TEST $STACK: Planning failed." + exit "$EXIT_CODE" + ;; + esac + + echo "::endgroup::" + done + # Remove temporary credentials even when verification fails. - name: Clean up Kubernetes credentials if: always()