Home / Docs / Developer docs / Deployment

Deployment

The app deploys to Cloudflare Workers from GitHub Actions; the website deploys through a Git-connected Cloudflare Pages project. This page covers the one-time setup, the workflows, and how to verify a release.

Developer docs. You want to read, run, deploy or change the code. Not what you came for? Find the right docs.

What deploys where

HostServesSourceHow
https://modscrim.dualmindlab.techStatic websitesite/Cloudflare Pages project modscrim, Git-connected
https://app.modscrim.dualmindlab.techApp Worker mod-fire-drill: SPA routes plus /api/*, /auth/*, /ws/*, /eventsubapp/deploy-app.yml, or npm run deploy
https://mod-fire-drill.creharsh.workers.devThe same Worker on workers.devapp/Same
https://mod-fire-drill-preview.creharsh.workers.devPreview Worker with its own databaseapp/ with CLOUDFLARE_ENV=previewpreview-app.yml

site/ is the website and app/ is the Worker: app routes, API calls and app screens never go into site/.

One-time setup

  1. Authenticate Wrangler: npx wrangler login.
  2. Create the D1 database mfd and put its ID in app/wrangler.jsonc.
  3. Apply migrations: npm run db:migrate:remote.
  4. Set the secrets, one npx wrangler secret put <NAME> per name. Run it from app/, and never paste values into the repository or a chat.
NamePurpose
PUBLIC_BASE_URLRedirect URI, webhook callback, links and the Origin check (https://app.modscrim.dualmindlab.tech in production)
TWITCH_CLIENT_SECRETOAuth token exchange
EVENTSUB_SECRETWebhook signatures (10 to 100 ASCII characters)
SESSION_HMAC_KEYCookies, tickets and participant tokens
TOKEN_ENC_KEYAES-256-GCM sealing of OAuth tokens

TWITCH_CLIENT_ID and the other settings (CHAT_LOG_RETENTION_DAYS, CLEAN_SET_MAX_LINES, GRADING_ENGINE, GRADING_BATCH_SIZE, GRADING_QUOTA_UNIT, DEMO_ENABLED, ANNOUNCE_ENABLED, COACH_AI_ENABLED) are public vars in the Wrangler config. The config lists the five secrets under secrets.required, so a deploy without them fails.

  1. Production-only report export: an R2 bucket and a Queue, both named mfd-reports, matching the config.
  2. In the Twitch Developer Console, register https://app.modscrim.dualmindlab.tech/auth/callback as the redirect URL; EventSub calls https://app.modscrim.dualmindlab.tech/eventsub.
  3. Deploy with npm run deploy (vite build && wrangler deploy), then open /api/health; it answers {"ok":true}. Optionally run npm run subscribe-revoke once to create the app-level revoke subscription.

The workflows

WorkflowTriggerWhat it does
deploy-app.ymlPush to main touching app/, packages/ or the root config; manualInstall, typecheck, test, apply D1 migrations to mfd, npm run deploy, then retry /api/health up to five times
preview-app.ymlPull requests to main touching the app (same-repo branches only)Same checks, migrations on mfd-preview, deploy the preview Worker, health check, and comment the link on the PR. One shared preview: the latest updated PR is what it shows
ci.ymlPull requests and pushes to mainGates described in Testing
e2e.ymlPull requests and pushes to mainPlaywright projects
site.ymlChanges under site/, the design tokens or the site specSite Playwright project and screenshots
demo-e2e.ymlNightly at 02:00 UTC; manual with a URLThe full demo loop against production
lighthouse.ymlManualLighthouse scores for the site and the console
firefox-console-check.ymlManual; changes to the console pageChecks that Enter in a console preview form does not reload the page in Firefox

The deploy and preview workflows need a CLOUDFLARE_API_TOKEN secret and a CLOUDFLARE_ACCOUNT_ID variable in the repository settings.

Verify a release

  • https://app.modscrim.dualmindlab.tech/api/health returns {"ok":true}.
  • https://app.modscrim.dualmindlab.tech/demo starts a demo drill.
  • Sign in with a test channel: the console shows the connection and the chat subscription becomes enabled.
  • Run the nightly demo workflow by hand if you need a fresh end-to-end check.

Do not deploy from a checkout that contains unreviewed local configuration or secrets.