Deployment Strategy Guide
π― Overview
This project uses a multi-environment deployment strategy with Firebase Hosting Channels:
main branch β Production (live)develop branch β Stagingfeature/* branches β Temporary preview URLsPull Requests β PR preview URLs (7-day expiration)π Environment URLs
Production
- URL: https://your-project-id.web.app
- Branch:
main - Deployment: Automatic on push
- Includes: Functions, Rules, Full deployment
Staging
- URL: https://your-project-idβstaging.web.app
- Branch:
develop - Deployment: Automatic on push
- Purpose: Test features before production
PR Previews
- URL: https://your-project-idβpr-{number}.web.app
- Trigger: Pull request opened/updated
- Expires: 7 days
- Purpose: Review changes before merging
π Recommended Git Workflow
1. Feature Development
# Create feature branch from developgit checkout developgit pull origin developgit checkout -b feature/new-feature
# Make changes and pushgit add .git commit -m "Add new feature"git push origin feature/new-feature2. Create Pull Request
- Target:
developbranch - Preview URL will be automatically created
- Share preview URL for review
3. Merge to Staging
# After PR approvalgit checkout developgit merge feature/new-featuregit push origin develop- Staging site updates automatically
4. Deploy to Production
# After testing on staginggit checkout maingit pull origin maingit merge developgit push origin main- Production deploys automatically
π Quick Commands
View All Preview Channels
firebase hosting:channel:listCreate Manual Preview
firebase hosting:channel:deploy preview-name --expires 7dDelete Preview Channel
firebase hosting:channel:delete preview-nameπ Benefits of This Approach
- Safety: Never deploy untested code to production
- Collaboration: Share preview URLs for feedback
- Testing: Test in staging before production
- Rollback: Easy to revert if issues arise
- Parallel Development: Multiple features can have their own previews
π‘οΈ Protection Rules
Consider adding these GitHub branch protection rules:
For main branch:
- Require pull request reviews
- Require status checks to pass
- Require branches to be up to date
- Include administrators
For develop branch:
- Require pull request reviews
- Require status checks to pass
π Monitoring Deployments
Check Deployment Status
# View all hosting sitesfirebase hosting:sites:list
# View specific channelfirebase hosting:channel:listAccess Different Environments
- Production: https://your-project-id.web.app
- Staging: https://your-project-idβstaging.web.app
- PR Preview: Check PR comments for URL
π‘ Best Practices
- Always test in staging before merging to main
- Use PR previews for code reviews
- Keep staging in sync with production data
- Tag releases in Git for tracking
- Document breaking changes in PR descriptions
π¨ Emergency Rollback
If something goes wrong in production:
# Quick rollback to previous commitgit checkout maingit reset --hard HEAD~1git push --force-with-lease origin main
# Or revert specific commitgit revert <commit-hash>git push origin mainπ Cost Considerations
- Preview Channels: Free, but count against hosting quota
- Multiple Sites: No additional cost
- Build Minutes: Each deployment uses GitHub Actions minutes
- Storage: Preview channels use Firebase Hosting storage
π§ Configuration
The deployment strategy is configured in:
.github/workflows/deploy-preview.yml- Main deployment workflowfirebase.json- Firebase configuration- Branch protection rules in GitHub settings