This directory contains CI/CD workflows for MOVA Smartlink Atom v1.
File: workflows/ci.yml
Trigger: Automatic on push/PR to main branch
What it does:
- ✅ Installs dependencies
- ✅ Builds core-smartlink library
- ✅ Lints all packages (worker + SPA)
- ✅ Runs unit tests (10 tests in core-smartlink)
- ✅ Builds SPA to verify production build works
- ✅ Verifies MOVA core files are not modified
Local equivalent:
npm run ciFile: workflows/deploy-worker.yml
Trigger:
- Manual (workflow_dispatch) with environment selection
- Automatic on version tags (
v*.*.*)
What it does:
- ✅ Builds and lints worker
- ✅ Deploys to Cloudflare Workers (production or staging)
- ✅ Verifies deployment
Required Secrets:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDCLOUDFLARE_SUBDOMAIN(optional)
Environment: Uses GitHub Environments for approval gates (optional)
File: workflows/deploy-pages.yml
Trigger:
- Manual (workflow_dispatch)
- Automatic on push to
main(when SPA files change)
What it does:
- ✅ Builds core-smartlink (dependency)
- ✅ Builds SPA production bundle
- ✅ Deploys to Cloudflare Pages
Required Secrets:
CLOUDFLARE_API_TOKENCLOUDFLARE_ACCOUNT_IDCLOUDFLARE_PAGES_PROJECT
-
API Token:
- Go to: https://dash.cloudflare.com/profile/api-tokens
- Click "Create Token"
- Use template: "Edit Cloudflare Workers"
- Add permissions:
- Account > Cloudflare Pages > Edit
- Account > Workers Scripts > Edit
- Copy the token (you'll only see it once!)
-
Account ID:
- Go to: https://dash.cloudflare.com/
- Select any site/domain
- Copy "Account ID" from the right sidebar
-
Pages Project Name:
- Go to: https://dash.cloudflare.com/ → Pages
- Create a new project (or note existing project name)
- Copy the project name (e.g.,
smartlink-admin)
- Go to your GitHub repository
- Navigate to: Settings → Secrets and variables → Actions
- Click "New repository secret"
- Add each secret:
| Secret Name | Value | Required For |
|---|---|---|
CLOUDFLARE_API_TOKEN |
Your API token from step 1 | Worker + Pages |
CLOUDFLARE_ACCOUNT_ID |
Your account ID from step 1 | Worker + Pages |
CLOUDFLARE_PAGES_PROJECT |
Your Pages project name | Pages only |
CLOUDFLARE_SUBDOMAIN |
Your workers.dev subdomain | Worker only (optional) |
Before first deployment, update packages/worker-smartlink/wrangler.toml:
[[kv_namespaces]]
binding = "KV_SMARTLINK_RULES"
id = "your_production_kv_id" # ← Replace with actual KV namespace ID
preview_id = "your_preview_kv_id"
[env.production]
name = "smartlink-worker" # Production worker name
vars = { ENVIRONMENT = "production" }
# Optional: add routes, custom domains, etc.Get production KV ID:
cd packages/worker-smartlink
npx wrangler kv:namespace create "KV_SMARTLINK_RULES"
# Copy the "id" value to wrangler.toml# From repository root
npm install
npm run cicd packages/worker-smartlink
npm run lint
# If passes, Worker is ready to deploycd packages/spa-admin
npm run build
ls -lh dist/ # Should see index.html and assetsJust push or create a PR:
git push origin main- Go to: Actions → Deploy Worker
- Click "Run workflow"
- Select environment (production/staging)
- Click "Run workflow"
git tag v1.0.0
git push origin v1.0.0- Go to: Actions → Deploy Pages
- Click "Run workflow"
- Click "Run workflow"
Fix: Core library not built. Workflow should build it first.
Fix: Check CLOUDFLARE_API_TOKEN is valid and has correct permissions.
Fix: Verify CLOUDFLARE_PAGES_PROJECT matches actual project name in Cloudflare dashboard.
Fix:
- Create KV namespace:
npx wrangler kv:namespace create "KV_SMARTLINK_RULES" - Update
wrangler.tomlwith productionid - Redeploy
Fix: CI detected changes to mova-core/ directory. These files should never be modified. Reset them:
git checkout mova-core/-
Always run CI locally before pushing:
npm run ci
-
Test deployments in staging first:
- Deploy to staging environment
- Verify functionality
- Then deploy to production
-
Use version tags for production releases:
git tag -a v1.0.0 -m "Release v1.0.0" git push origin v1.0.0 -
Monitor deployments:
- Check GitHub Actions logs
- Monitor Cloudflare Workers analytics
- Test deployed URLs immediately
-
Never commit secrets:
- Always use GitHub Secrets
- Never hardcode API tokens in code
- Review changes before committing
- API tokens have read/write access to Workers and Pages
- Use scoped tokens (not Global API Key)
- Rotate tokens periodically
- Use GitHub Environments for approval gates on production deployments
- Review deployment logs for sensitive information
For more details, see:
- COMMANDS.md - Command reference
- SETUP.md - Setup guide
- BUILD_AND_TEST_REPORT.md - Build verification