Deployment Playbook
Step-by-step guide for deploying changes to production.
Overview
Safe, reliable deployment process for shipping changes.
Pre-Deployment Checklist
- All tests passing
- Code reviewed and approved
- No critical bugs
- Database migrations ready
- Environment variables configured
- Rollback plan documented
Deployment Process
1. Verify Staging
Before deploying to production:
# Check staging is up to date
git log origin/main --oneline -5
# Verify staging environment
curl https://staging.example.com/health
Test critical flows:
- User can sign up
- User can log in
- Core feature works
- No errors in logs
2. Deploy to Production
Vercel (automatic)
# Merge to main triggers deployment
git checkout main
git merge staging
git push
Manual deployment
# Build
npm run build
# Deploy
npm run deploy
3. Post-Deployment Verification
Immediately after deploy:
- Check health endpoint
- Verify homepage loads
- Test login flow
- Check error monitoring
- Monitor performance metrics
# Quick health check
curl https://production.example.com/health
# Check for errors
# (check your monitoring tool)
4. Monitor
Watch for 15-30 minutes:
- Error rates
- Response times
- User complaints
Rollback Plan
If issues are detected:
Quick Rollback (Vercel)
- Go to Vercel dashboard
- Find last working deployment
- Click "Promote to Production"
Manual Rollback
# Find last good commit
git log --oneline -10
# Revert to that commit
git revert HEAD
git push
# Or force deploy previous version
git checkout [commit-hash]
git push -f origin main # Use with caution!
Database Migrations
If deployment includes database changes:
-
Backup first
pg_dump production_db > backup_$(date +%Y%m%d).sql -
Run migrations
npm run db:migrate -
Verify data integrity
- Check record counts
- Verify critical data exists
- Test queries work
Troubleshooting
Deployment Failed
- Check build logs
- Verify environment variables
- Check for missing dependencies
Site Down After Deploy
- Check error logs
- Verify database connection
- Rollback if needed
- Fix and redeploy
Performance Degradation
- Check monitoring dashboards
- Look for N+1 queries
- Check for memory leaks
- Scale resources if needed