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