deploying-tray-worker
Quick Reference
Run these commands from the repository root unless a command changes directories.
# Verify the active Cloudflare account.
npx wrangler whoami
# Build the UI required by the hub worker.
npm run build -w @slicc/webapp
# Read-only, fail-closed prerequisite BEFORE any deploy or secret mutation.
# Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in the environment.
node packages/cloudflare-worker/scripts/verify-preview-lifecycle.mjs sliccy-now-basic-storage
# Upload assets to R2 BEFORE deploying (mandatory gate).
node packages/cloudflare-worker/scripts/upload-assets-to-r2.mjs \
slicc-asset-archive-staging --dir dist/ui/assets
# Deploy the staging hub and preview workers as a pair.
cd packages/cloudflare-worker
npx wrangler deploy --config wrangler.jsonc --env staging
npx wrangler deploy --config wrangler-preview.jsonc --env staging
# Verify R2 buckets and retention rules.
npx wrangler r2 bucket list
npx wrangler r2 bucket lifecycle list slicc-asset-archive
npx wrangler r2 bucket lifecycle list slicc-asset-archive-staging
# Run deployed worker smoke tests.
WORKER_BASE_URL=https://... npm test -- tests/deployed.test.ts
# Live-preview round trip (needs BOTH hub and preview worker deployed): a
# scripted leader serves 16 MiB (tray DO must survive), 25 MiB + 1 (clean 413),
# fills the 10-snapshot quota (live mints still succeed; pending uploads are
# listed). CI runs it after the staging preview deploy.
WORKER_BASE_URL=https://... npm test -- tests/deployed-live-preview.test.ts
Use this skill as the operational runbook for packages/cloudflare-worker/. See