You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wrangler.jsonc is generated and gitignored. It is the only config used by wrangler dev and wrangler deploy.
4. Develop
npm run dev # Vite + Worker with HMR (single server)
npm run db:migrate:local # apply D1 migrations locally
npm run test# unit tests
npm run test:e2e # e2e tests
5. Required Cloudflare Resources (One-Time Setup)
Create once before the first deploy. CI only deploys code; it does not provision resources.
Resource
Command
D1 Database
wrangler d1 create bits-social-manager
Custom domain is auto-provisioned on deploy from routes: [{ "pattern": "${APP_DOMAIN}", "custom_domain": true }] in wrangler.template.jsonc. Ensure the zone for APP_DOMAIN is active in Cloudflare.
6. Deploy
Option A — Local Deploy
Best for quick iteration from your machine.
npx wrangler login
npm run cf:config
npm run db:migrate:remote
npm run deploy
# equivalent to: npm run build && wrangler deploy
Option B — Remote Deploy via GitHub Actions (Recommended)
Best for production and team workflows. Triggered manually via workflow_dispatch.
Configure GitHub Variables and Secrets (tables below) at Settings → Secrets and variables → Actions.
Go to Actions → Deploy → Run workflow.
Pushes to main do not auto-deploy.
GitHub Variables
Variable
Example
Required
Description
WORKER_NAME
bits-social-manager
Required
Worker name
D1_DATABASE_NAME
bits-social-manager
Required
D1 database name
D1_DATABASE_ID
xxxx-xxxx-xxxx
Required
D1 database ID from wrangler d1 create
APP_URL
https://social.bits.co.id
Required
Public URL
APP_DOMAIN
social.bits.co.id
Required
Custom domain
GitHub Secrets
Secret
Required
Description
CLOUDFLARE_API_TOKEN
Required
Cloudflare API token with Workers Edit permission
CLOUDFLARE_ACCOUNT_ID
Required
Cloudflare Account ID
JWT_SECRET
Required
Min 32 chars, openssl rand -base64 48
ENCRYPTION_KEY
Required
64 hex chars (32 bytes), openssl rand -hex 32
Secrets are synced via wrangler secret bulk during deploy. For local development, set them in .dev.vars.