This guide explains how to set up GitHub Actions CI/CD for automatic deployment to Cloudflare Workers and Pages.
Your repository is now private at: https://github.com/ciscoittech/binary-math-system
To enable automatic deployment, you must add the following secrets to your GitHub repository:
- Go to: https://github.com/ciscoittech/binary-math-system/settings/secrets/actions
- Click "New repository secret"
| Secret Name | Description | Where to Get |
|---|---|---|
CLOUDFLARE_API_TOKEN |
API token for Cloudflare | Cloudflare Dashboard |
CLOUDFLARE_ACCOUNT_ID |
Your Cloudflare Account ID | Cloudflare Dashboard |
TURSO_URL |
Turso database connection URL | Turso Dashboard |
TURSO_AUTH_TOKEN |
Turso authentication token | Turso Dashboard |
OPENROUTER_API_KEY |
OpenRouter API key (if using AI features) | OpenRouter |
wrangler.toml file currently contains exposed secrets. You should:
-
Rotate credentials immediately:
# Regenerate all tokens in their respective dashboards -
Update wrangler.toml to use environment variables:
[env.production] routes = [ { pattern = "api.binarymath.dev", custom_domain = true } ] [[kv_namespaces]] binding = "KV" id = "binary-kv"
-
Add to .gitignore:
.env .env.local .env.*.local wrangler.toml.local
The workflow file .github/workflows/deploy.yml runs on:
- Push to main: Full test and deploy
- Pull requests: Tests only (no deployment)
-
Test Stage
- Tests both
binary-math-apiandbinary-math-web - Builds both components
- Runs on all PRs and pushes
- Tests both
-
Deploy API Stage (main branch only)
- Builds the Cloudflare Workers API
- Deploys to production environment
- Uses
npm run buildthenwrangler deploy --env production
-
Deploy Web Stage (main branch only)
- Builds the React/Vite frontend
- Deploys to Cloudflare Pages
- Uses
wrangler pages deploy
npm install -g wrangler
npm install -g @cloudflare/wrangler# API
cd binary-math-api
npm install
# Web
cd binary-math-web
npm install# API tests
cd binary-math-api
npm test
# Web tests
cd binary-math-web
npm testcd binary-math-api
wrangler deploy --env production- Go to: https://github.com/ciscoittech/binary-math-system/actions
- Click on any workflow run to see detailed logs
Build Failures
- Check the GitHub Actions logs
- Verify all dependencies are installed:
npm ci - Ensure Node.js version matches (20.x)
Deployment Failures
- Verify Cloudflare secrets are set correctly
- Check that Cloudflare account is active
- Verify custom domain is configured in Cloudflare
Test Failures
- Run tests locally:
npm test - Check test output for specific failures
- Update code and push to retry
After successful deployment:
- API: https://api.binarymath.dev
- Web: https://binary-math.pages.dev (or custom domain if configured)
The workflow is defined in .github/workflows/deploy.yml and includes:
- Test Matrix: Tests run in parallel for API and Web
- Cache: Dependencies are cached for faster builds
- Conditional Deployment: Only deploys on main branch pushes
- Status Reporting: Shows deployment status after completion
When using Claude agents to make updates:
- Agents commit changes to feature branches
- Agents create pull requests (tests run automatically)
- Review and merge to main (deployment triggered)
- Deployment completes automatically via GitHub Actions
# Agent creates branch
git checkout -b agent/feature-name
# Agent makes changes
# Agent commits
git commit -m "feat: description"
# Agent pushes
git push origin agent/feature-name
# Agent creates PR
gh pr create --title "Feature: description"
# PR passes tests automatically
# After merge to main
# GitHub Actions automatically deploysFor issues with:
- Cloudflare: https://support.cloudflare.com
- GitHub Actions: Check workflow logs or GitHub docs
- Wrangler CLI:
wrangler --helpor https://developers.cloudflare.com/workers/wrangler/
Last Updated: 2025-10-15