Setup QA Deploy
Quick guide to enable automatic QA deployment on branch dev with a dedicated QA D1 database.
Prerequisites
- Cloudflare account with Workers and Pages enabled
- GitHub repository with GitHub Actions enabled
- Local
wranglerCLI (v4.80.0+)
Step 1: Create the QA D1 Database
Run locally:
cd backend
npx wrangler d1 create fantasydb-qa --remoteExpected output:
✓ Created new D1 database 'fantasydb-qa'
Created D1 database 'fantasydb-qa' with ID: 12345678-1234-1234-1234-123456789012Save the database_id (example: 12345678-1234-1234-1234-123456789012).
Step 2: Add GitHub Secret
- Go to: https://github.com/luca0patrignani/FantasyWiki/settings/secrets/actions
- Click "New repository secret"
- Name:
D1_QA_DATABASE_ID - Value: paste the database ID from Step 1
- Click "Add secret"
Step 3: Verify Existing Secrets
Make sure these secrets already exist:
CLOUDFLARE_API_TOKEN: da https://dash.cloudflare.com/profile/api-tokensCLOUDFLARE_ACCOUNT_ID: da https://dash.cloudflare.com (Account ID)
If any are missing, add them with the same process as Step 2.
Step 4: Create the QA Pages Project
- Create a Cloudflare Pages project named
frontend-qa - Use the same build/output settings as the production project
frontend
Step 5: Create Branch dev
git checkout -b dev
git push origin devGitHub Actions will automatically run the deploy.yml workflow.
Step 6: Verify Deployment
Go to: https://github.com/luca0patrignani/FantasyWiki/actions
Find the "Deploy" workflow. The following jobs should pass:
- ✅ check
- ✅ deploy-backend (matrix: dev)
- ✅ deploy-frontend (matrix: dev)
- ✅ migrate-d1 (matrix: dev)
If migrate-d1 fails on dev, ensure:
D1_QA_DATABASE_IDis configured (Step 2)- The QA database exists on Cloudflare (
wrangler d1 list --remote)
Manual Trigger
If you need to deploy QA without a push:
- Open: https://github.com/luca0patrignani/FantasyWiki/actions/workflows/deploy.yml
- Click "Run workflow"
- Select branch:
dev - Click "Run workflow"
QA Rollback
If QA is broken:
git revert <commit-hash>
git push origin devThe workflow will redeploy with the reverted code.
QA Target Environment
After deployment, QA is available on:
- Backend API:
backend-qa.luca0patrignani.workers.dev/api - Frontend: domain associated with the
frontend-qaPages project - Database:
fantasydb-qa(D1 remote)
Troubleshooting
migrate-d1 job fails
ERROR: D1_QA_DATABASE_ID secret is not setFix: add D1_QA_DATABASE_ID as a GitHub secret (Step 2).
QA backend cannot reach frontend
If you see CORS or redirect issues, check:
backend/wrangler.jsoncQA env vars (FRONTEND_URL)- local frontend env points to the local backend (
VITE_BACKEND_URL=http://127.0.0.1:8787) during local testing
Frontend cannot reach QA backend
If build or runtime fails due to backend URL:
- verify
deploy-frontend(dev branch entry) usesVITE_BACKEND_URL: backend-qa.luca0patrignani.workers.dev
Next Steps
- Read the full deploy strategy
- Configure D1 migrations (optional)
- Validate on
devbefore opening a PR tomaster
