fix(preview): delete stale container app before redeploy (#1820)

This commit is contained in:
Sure Admin (bot)
2026-05-17 20:24:45 +02:00
committed by GitHub
parent 34ec12b448
commit 4c7d3638fd

View File

@@ -82,6 +82,28 @@ jobs:
sed -i "s/\${PR_NUMBER}/${{ github.event.pull_request.number }}/g" src/index.ts
cat wrangler.toml
- name: Delete existing preview container app before redeploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
working-directory: workers/preview
run: |
CONTAINER_NAME="sure-preview-${{ github.event.pull_request.number }}-railscontainer"
echo "Looking for stale preview container app: $CONTAINER_NAME"
CONTAINER_ID=$(npx wrangler containers list --json | jq -r --arg NAME "$CONTAINER_NAME" '
map(select((.name // .application_name // .app_name // "") == $NAME))
| first
| (.id // .container_id // .application_id // empty)
')
if [ -n "$CONTAINER_ID" ]; then
echo "Deleting stale preview container app $CONTAINER_NAME ($CONTAINER_ID)"
npx wrangler containers delete "$CONTAINER_ID"
else
echo "No stale preview container app found; continuing"
fi
- name: Delete existing preview Worker before redeploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}