Deployment Pipeline
The deployment pipeline is fully automated via GitHub Actions. Every push to main triggers a build and automatic deployment to Cloudflare Pages.
Deployment Triggers
- Automatic: Every push to main branch
- Manual: Trigger workflow from GitHub Actions tab
- Re-deploy: Push empty commit or trigger workflow manually
Deployment Workflow Steps
1. Checkout Code
GitHub Actions checks out the latest commit from main branch.2. Setup Node Environment
Install Node.js 20.x and npm 9.x (pinned versions for reproducibility).3. Install Dependencies
bash
npm ci
Installs exact dependency versions from package-lock.json (reproducible builds).
4. Type Checking
bash
npm run type-check
TypeScript compiler validates all code. Errors fail the build immediately.
5. Content Validation
Custom scripts validate:- All MDX files have required frontmatter fields
- All JSON data files conform to Zod schemas
- All slugs are unique within sections
- All referenced images and assets exist
- No broken internal links
Validation failures stop the build.
6. Build Static Export
bash
npm run build
Next.js builds the application and exports to static HTML/CSS/JavaScript.
7. Optimize Assets
Automated optimization:- CSS minification and purging unused styles
- JavaScript minification
- Image optimization (AVIF, WebP fallbacks)
- Font subset generation
8. Deploy to Cloudflare Pages
Cloudflare Pages API automatically deploys the static build:- Upload
out/directory contents - Assign preview URL for this deployment
- Update production domain if on main
- Purge Cloudflare cache
9. Notify Status
GitHub Actions displays deployment status:- Success: "Deployed to production"
- Failure: "Build failed, check logs"
Rollback Procedure
To rollback a bad deployment:
bash
Identify the bad commit
git log --oneline -5
Revert it
git revert <commit-hash>
This creates a NEW commit that undoes the changes
git push
CI automatically rebuilds and deploys the reverted state
Important: Use git revert, not git reset --hard. Revert creates a new commit, preserving history.
Manual Deployment (if needed)
For manual deployment without GitHub Actions:
bash
Install dependencies
npm ci
Run validation
npm run validate
Build static site
npm run build
Export to static files
npm run export
Deploy to Cloudflare (using wrangler CLI)
npm install -g @cloudflare/wrangler
wrangler pages deploy out
Deployment Checklist
Before pushing to main (for major releases):
- [ ] All TypeScript type errors resolved
- [ ] All content validates against schemas
- [ ] No broken internal links
- [ ] All images optimized
- [ ] Accessibility audit passed (WAVE)
- [ ] Mobile responsive testing done
- [ ] Performance budget not exceeded
- [ ] Changelog entry created
- [ ] Git commit message is clear
For routine content updates, standard validation is automatic.
Post-Deployment Verification
After deployment:
- 1. Check deployment status: View GitHub Actions logs
- 2. Visit production: Load the site and do spot checks
- 3. Check Cloudflare: View edge cache and analytics
- 4. Run link checker: Validate no broken links in production
- 5. Monitor analytics: Watch for any unusual traffic patterns
If issues are found, rollback immediately with git revert.
Deployment Frequency and Safety
Deployments happen on every push to main. This is safe because:
- All changes are tested in CI before deployment
- Rollback is instant (60 second redeploy of previous commit)
- No data loss possible (all content in Git)
- No approval gates needed (static content, low risk)
- Git history is preserved (every change tracked)
This enables rapid iteration while maintaining stability.
Monitoring After Deployment
Key metrics to monitor post-deployment:
| Metric | Tool | Action | |---|---|---| | Build status | GitHub Actions | Immediate notification on failure | | Page load time | Cloudflare Analytics | Alert if >2s average load | | Traffic/errors | Cloudflare Analytics | Watch for spikes or errors | | Link health | Custom link checker | Daily broken link report | | Uptime | Cloudflare SLA | Inherited 99.95% guarantee |
Deployment Disasters
If deployment fails:
- 1. Check GitHub Actions logs for error
- 2. Fix the issue in code
- 3. Push to main (redeploy)
- 4. If urgent, revert previous commit while fixing
If production is broken:
- 1.
git revert HEAD(reverts to previous working state) - 2.
git push(CI redeploys) - 3. Fix the actual issue on a branch
- 4. Create PR, merge, deploy
If you need to skip a commit:
bash
git revert <bad-commit-hash>
git push
Creates a new commit that undoes the bad one
All disaster scenarios have recovery paths under 5 minutes.