Deployment Procedures
Every deployment is a risk. Minimize risk through preparation, not speed.
1. Pre-Deployment Principles
The 4 Verification Categories
| Category |
What to Check |
| Code Quality |
Tests passing, linting clean, reviewed |
| Build |
Production build works, no warnings |
| Environment |
Env vars set, secrets current |
| Safety |
Backup done, rollback plan ready |
Pre-Deployment Checklist
2. The 5-Phase Deployment Process
1. PREPARE
└── Verify code, build, env vars
2. BACKUP
└── Save current state before changing
3. DEPLOY
└── Execute with monitoring open
4. VERIFY
└── Health check, logs, key flows
5. CONFIRM or ROLLBACK
└── All good? Confirm. Issues? Rollback.
Phase Principles
| Phase |
Principle |
| Prepare |
Never deploy untested code |
| Backup |
Can't rollback without backup |
| Deploy |
Watch it happen, don't walk away |
| Verify |
Trust but verify |
| Confirm |
Have rollback trigger ready |
3. Platform-Specific Procedures
Vercel
# Preview deploy (automatic on PR)
git push origin feature-branch
# Production deploy
git push origin main
# or
vercel --prod
Firebase
# Deploy hosting
firebase deploy --only hosting
# Deploy functions
firebase deploy --only functions
Docker/VPS
# Build and push
docker build -t app:latest .
docker push registry/app:latest
# On server
docker pull registry/app:latest
docker-compose up -d
4. Rollback Strategies
When to Rollback
| Symptom |
Action |
| 5xx errors |
Rollback immediately |
| Critical feature broken |
Rollback |
| Minor visual bug |
Hotfix forward |
| Performance degradation |
Evaluate, then decide |
Rollback by Platform
| Platform |
Method |
| Vercel |
Redeploy previous commit, or use dashboard |
| Firebase |
firebase hosting:rollback |
| Docker |
Switch to previous image tag |
5. Zero-Downtime Strategies
| Strategy |
When to Use |
| Blue-Green |
Multiple servers, quick switch |
| Rolling |
Gradual, Kubernetes |
| Canary |
Test with subset of users |
6. Anti-Patterns
| ❌ Don't |
✅ Do |
| Deploy on Friday |
Deploy early in week |
| Rush deployment |
Follow the process |
| Skip staging |
Always test first |
| Deploy without backup |
Backup before deploy |
| Walk away after deploy |
Monitor for 15+ min |
| Multiple changes at once |
One change at a time |
7. Decision Checklist
Before deploying:
8. Best Practices
- Small, frequent deploys over big releases
- Feature flags for risky changes
- Automate repetitive steps
- Document every deployment
- Review what went wrong after issues
- Test rollback before you need it
9. Example Deployment Flow
develop → staging (auto) → main → production (auto)
│ │ │
└── PR ────┴── Review ────┴── Deploy
Branch Protection
main requires PR approval
- CI must pass before merge
- No force push allowed
Golden Rule: If in doubt, don't deploy. Wait, prepare, then deploy.
1---2name: deployment-procedures3description: Production deployment workflows, rollback strategies, and CI/CD best practices.4version: 1.0.05allowed-tools: Read, Glob, Grep, Bash6---78# Deployment Procedures910> Every deployment is a risk. Minimize risk through preparation, not speed.1112---1314## 1. Pre-Deployment Principles1516### The 4 Verification Categories1718| Category | What to Check |19| ---------------- | -------------------------------------- |20| **Code Quality** | Tests passing, linting clean, reviewed |21| **Build** | Production build works, no warnings |22| **Environment** | Env vars set, secrets current |23| **Safety** | Backup done, rollback plan ready |2425### Pre-Deployment Checklist2627- [ ] All tests passing28- [ ] Code reviewed and approved29- [ ] Production build successful30- [ ] Environment variables verified31- [ ] Database migrations ready (if any)32- [ ] Rollback plan documented33- [ ] Team notified34- [ ] Monitoring ready3536---3738## 2. The 5-Phase Deployment Process3940```411. PREPARE42 └── Verify code, build, env vars43442. BACKUP45 └── Save current state before changing46473. DEPLOY48 └── Execute with monitoring open49504. VERIFY51 └── Health check, logs, key flows52535. CONFIRM or ROLLBACK54 └── All good? Confirm. Issues? Rollback.55```5657### Phase Principles5859| Phase | Principle |60| ----------- | -------------------------------- |61| **Prepare** | Never deploy untested code |62| **Backup** | Can't rollback without backup |63| **Deploy** | Watch it happen, don't walk away |64| **Verify** | Trust but verify |65| **Confirm** | Have rollback trigger ready |6667---6869## 3. Platform-Specific Procedures7071### Vercel7273```bash74# Preview deploy (automatic on PR)75git push origin feature-branch7677# Production deploy78git push origin main79# or80vercel --prod81```8283### Firebase8485```bash86# Deploy hosting87firebase deploy --only hosting8889# Deploy functions90firebase deploy --only functions91```9293### Docker/VPS9495```bash96# Build and push97docker build -t app:latest .98docker push registry/app:latest99100# On server101docker pull registry/app:latest102docker-compose up -d103```104105---106107## 4. Rollback Strategies108109### When to Rollback110111| Symptom | Action |112| ----------------------- | --------------------- |113| 5xx errors | Rollback immediately |114| Critical feature broken | Rollback |115| Minor visual bug | Hotfix forward |116| Performance degradation | Evaluate, then decide |117118### Rollback by Platform119120| Platform | Method |121| -------- | ------------------------------------------ |122| Vercel | Redeploy previous commit, or use dashboard |123| Firebase | `firebase hosting:rollback` |124| Docker | Switch to previous image tag |125126---127128## 5. Zero-Downtime Strategies129130| Strategy | When to Use |131| ---------- | ------------------------------ |132| Blue-Green | Multiple servers, quick switch |133| Rolling | Gradual, Kubernetes |134| Canary | Test with subset of users |135136---137138## 6. Anti-Patterns139140| ❌ Don't | ✅ Do |141| ------------------------ | -------------------- |142| Deploy on Friday | Deploy early in week |143| Rush deployment | Follow the process |144| Skip staging | Always test first |145| Deploy without backup | Backup before deploy |146| Walk away after deploy | Monitor for 15+ min |147| Multiple changes at once | One change at a time |148149---150151## 7. Decision Checklist152153Before deploying:154155- [ ] Platform-appropriate procedure?156- [ ] Backup strategy ready?157- [ ] Rollback plan documented?158- [ ] Monitoring configured?159- [ ] Team notified?160- [ ] Time to monitor after?161162---163164## 8. Best Practices1651661. **Small, frequent deploys** over big releases1672. **Feature flags** for risky changes1683. **Automate** repetitive steps1694. **Document** every deployment1705. **Review** what went wrong after issues1716. **Test rollback** before you need it172173---174175## 9. Example Deployment Flow176177```178develop → staging (auto) → main → production (auto)179 │ │ │180 └── PR ────┴── Review ────┴── Deploy181```182183### Branch Protection184185- `main` requires PR approval186- CI must pass before merge187- No force push allowed188189---190191> **Golden Rule:** If in doubt, don't deploy. Wait, prepare, then deploy.