From 34ec12b44895121e36c2052dea5ed091139827a3 Mon Sep 17 00:00:00 2001 From: "Sure Admin (bot)" Date: Sun, 17 May 2026 19:59:46 +0200 Subject: [PATCH] fix(preview): replace PR preview cleanly on redeploy (#1819) --- .github/workflows/preview-deploy.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml index eff9c847a..269adf510 100644 --- a/.github/workflows/preview-deploy.yml +++ b/.github/workflows/preview-deploy.yml @@ -82,6 +82,16 @@ jobs: sed -i "s/\${PR_NUMBER}/${{ github.event.pull_request.number }}/g" src/index.ts cat wrangler.toml + - name: Delete existing preview Worker before redeploy + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + working-directory: workers/preview + run: | + WORKER_NAME="sure-preview-${{ github.event.pull_request.number }}" + echo "Ensuring fresh preview deployment for $WORKER_NAME" + npx wrangler delete --name "$WORKER_NAME" --force || echo "Existing preview not found; continuing" + - name: Create GitHub Deployment id: deployment uses: actions/github-script@v7