GitHub Secrets & Token Management
This runbook explains the GitHub Secrets used across Factory Core and all Factory apps, with special attention to the CloudFlare token naming issue.CloudFlare Token Confusion: CF_API_TOKEN vs. CLOUDFLARE_API_TOKEN
⚠️ IMPORTANT: There are two different environment variable names for CloudFlare API tokens, and this causes confusion.Current State
Why We Have Two
The naming inconsistency occurred because:- Different CloudFlare tools expect different env var names
- Wrangler uses
CF_API_TOKENnatively - Older CloudFlare documentation referenced
CLOUDFLARE_API_TOKEN - Both were created at different times without consolidation
Action Required
For all app repositories:- ✅ In
.github/workflows/deploy.yml, verify it uses:
- ❌ Never use:
- In
wrangler.jsonc, do not setapi_token— let it read fromCF_API_TOKENenv var
Complete GitHub Secrets Inventory
Required for Factory Core (monorepo)
Required for Each App Repository
Required for Factory Video Rendering Pipeline
These secrets are required beforeapps/schedule-worker, apps/video-cron, and the render-video.yml workflow can complete a synthetic job flow.
Required for Prime Self Smoke Validation
These secrets are required by.github/workflows/smoke-prime-self.yml and apps/prime-self-smoke/tests/workspace-contract.spec.ts.
Without them, authenticated workspace contract checks (personal + practitioner route/tool discoverability) will fail in CI.
Canonical contract note: use only
SMOKE_USER_* and SMOKE_PRACTITIONER_* secrets.
Legacy SMOKE_EMAIL / SMOKE_PASSWORD aliases are no longer used by CI workflows.
How to Set GitHub Secrets
For Factory Core (monorepo)
- Navigate to: https://github.com/adrper79-dot/Factory/settings/secrets/actions
- Click “New repository secret”
- Add each secret from the inventory above
- Verify in workflows: Go to Actions → select any workflow → check “Secrets” are populated
For Each App (original 6 apps + any standalone apps)
The original 6 apps (prime-self, wordis-bond, cypher-healing, the-calling, ijustus, neighbor-aid) usesetup-all-apps.mjs for bulk setup.
Standalone apps added after Stage 6 (xpelevator, xico-city, and any future apps) use their own setup-{app}-secrets.yml workflow in the Factory repo instead.
- Navigate to: https://github.com/adrper79-dot/{app}/settings/secrets/actions
- Click “New repository secret”
- Add secrets from “Required for Each App Repository” table
- Commit the app’s
wrangler.jsoncto reference via interpolation
Setting Secrets in wrangler.jsonc
✅ Good — Reference via env var:Wrangler Secret vs. GitHub Secret
JWT_SECRET Example:
Rotation Schedule
Troubleshooting
Error: “403 Forbidden: PUT https://npm.pkg.github.com”
Cause:NODE_AUTH_TOKEN is missing or expiredFix:
- Generate new GitHub PAT: https://github.com/settings/tokens?type=beta
- Scopes needed:
read:packagesonly - Update Secret: https://github.com/adrper79-dot/{repo}/settings/secrets/actions
- Re-run workflow
Error: “Unauthorized: CF_API_TOKEN invalid”
Cause: Token name mismatch (CLOUDFLARE_API_TOKEN used instead of CF_API_TOKEN)Fix:
- Check
.github/workflows/deploy.ymlfor correct env var name - Verify GitHub Secrets page lists
CF_API_TOKEN(notCLOUDFLARE_API_TOKEN) - Test locally:
CF_API_TOKEN=xxx wrangler deploy
Error: “Failed to connect to database: ECONNREFUSED”
Cause:NEON_URL / DATABASE_URL is wrong or expiredFix:
- In Neon console: Project → Connection string → Copy fresh string
- Update GitHub Secrets:
NEON_URLorDATABASE_URL(match app’s naming convention) - Redeploy:
wrangler deploy --env production
Error: “Sentry 401: Invalid DSN”
Cause:SENTRY_DSN is missing or typo’dFix:
- In Sentry: Settings → Projects → → Client Keys (DSN)
- Copy exact URL
- Update GitHub Secrets:
SENTRY_DSN - Redeploy
Error: “render-video workflow secret not found”
Cause: One of the video rendering pipeline secrets is missing from GitHub Actions. Fix:- Compare the repository secrets against the “Required for Factory Video Rendering Pipeline” table above.
- Add the missing secret in Settings → Secrets and variables → Actions.
- Re-run the failed workflow and verify the schedule-worker callback succeeds.
Audit Checklist
Run this quarterly:- All Factory app repos have
CF_API_TOKENset (original 6 + xpelevator + xico-city + any new standalone apps) - No repo has
CLOUDFLARE_API_TOKENset without also havingCF_API_TOKEN(both are needed for compatibility) - Each app has
SENTRY_DSNandPOSTHOG_KEYset as Wrangler secrets (not GitHub Secrets) -
NODE_AUTH_TOKEN/GH_PATis fresh (< 90 days old) - Wrangler secrets are up to date (run
wrangler secret list --name {app}per app) - No hardcoded passwords in
wrangler.jsoncor source code -
HYPERDRIVE_*secrets exist in Factory repo for all apps with standalone workflows - Rate limiter ID registry in add-new-app.md is up to date
Related Runbooks
- Deployment Runbook — How to deploy with these secrets
- Secret Rotation Runbook — How to rotate specific secrets
- Add New App Runbook — Per-app secret naming conventions when onboarding a new standalone app