From 5edef0e308ce234da69e4bedfaf05149cabcbca6 Mon Sep 17 00:00:00 2001 From: Jordan Kab Date: Fri, 12 Jun 2026 15:31:45 -0400 Subject: [PATCH] fix(THU-539): skip pulumi destroy when stack is already gone Preview teardown ran `pulumi destroy` unconditionally, so any PR whose stack was already torn down (manual destroy, a prior failed run, or a PR that never deployed) failed with "no stack named ... found" and surfaced a red x on close. Guard destroy behind a stack-existence check so a clean environment is treated as success. Co-Authored-By: Claude Opus 4.8 (1M context) --- .github/workflows/stack-deploy.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/stack-deploy.yml b/.github/workflows/stack-deploy.yml index c2964d2de..d57ed6005 100644 --- a/.github/workflows/stack-deploy.yml +++ b/.github/workflows/stack-deploy.yml @@ -243,7 +243,26 @@ jobs: working-directory: deploy/pulumi run: bun install --frozen-lockfile + # Destroy must be idempotent: the stack may already be gone (manual destroy, + # a prior run that tore it down but still failed, or a PR that never deployed). + # Without this guard `pulumi destroy` errors with "no stack named ... found", + # surfacing a red ✗ on every PR close even though the env is already clean (THU-539). + - name: Check whether the stack still exists + id: stack_check + working-directory: deploy/pulumi + run: | + curl -fsSL https://get.pulumi.com | sh + export PATH="$HOME/.pulumi/bin:$PATH" + if pulumi stack select "${{ inputs.stack_name }}" --non-interactive 2>/dev/null; then + echo "Stack ${{ inputs.stack_name }} exists — proceeding to destroy." + echo "exists=true" >> "$GITHUB_OUTPUT" + else + echo "Stack ${{ inputs.stack_name }} not found — nothing to destroy." + echo "exists=false" >> "$GITHUB_OUTPUT" + fi + - name: Destroy + if: steps.stack_check.outputs.exists == 'true' uses: pulumi/actions@8e5e406f4007fca908480587cb9893c07090f58d # v7.0.0 with: command: destroy