Deployment Automation Guide¶
Overview¶
DSTA uses automated deployment with blue-green strategy for zero-downtime deployments.
Deployment Scripts¶
Production Deployment¶
Features: - Blue-green deployment - Automatic health checks - Automatic rollback on failure - Slack notifications - Database migrations - Static file collection
Staging Deployment¶
Features: - Quick deployment for testing - Health checks - Migration execution
CI/CD Pipeline¶
GitHub Actions workflow: .github/workflows/deploy.yml
Workflow Stages¶
- Test: Run unit tests and code coverage
- Build: Build Docker images for all services
- Deploy Staging: Automatic deployment to staging on main branch
- Deploy Production: Manual approval for production deployment
Triggers¶
- Push to main: Deploy to staging
- Version tags (v..*): Deploy to production
- Manual dispatch: Deploy to selected environment
Blue-Green Deployment¶
The production deployment uses blue-green strategy:
- Build new images (green)
- Run database migrations
- Scale up new instances
- Health check new instances
- Switch traffic to new instances
- Scale down old instances (blue)
- Cleanup
Health Checks¶
All deployments verify: - HTTP endpoint accessibility - API response validity - Database connectivity - Service availability
Rollback¶
Automatic rollback on: - Health check failure - Migration errors - Service start failure
Manual rollback:
Notifications¶
Slack notifications sent for: - Deployment start - Deployment success - Deployment failure - Rollback events
Configure webhook: SLACK_WEBHOOK_URL environment variable
Secrets Management¶
Required GitHub Secrets: - STAGING_HOST: Staging server hostname - STAGING_USERNAME: SSH username - STAGING_SSH_KEY: SSH private key - PRODUCTION_HOST: Production server hostname - PRODUCTION_USERNAME: SSH username
- PRODUCTION_SSH_KEY: SSH private key - SLACK_WEBHOOK_URL: Slack webhook for notifications
Monitoring¶
Monitor deployments: - GitHub Actions: https://github.com/your-repo/actions - Slack: #dsta-deployments channel - Grafana: Deployment annotations
Best Practices¶
- Always deploy to staging first
- Run smoke tests after staging deployment
- Monitor metrics after production deployment
- Keep deployment scripts in version control
- Document deployment changes
Troubleshooting¶
Deployment Fails¶
Check logs:
Health Check Fails¶
Verify endpoint:
Rollback Needed¶
Manual rollback:
Version History¶
- 1.0.0 (2025-01-27): Initial deployment automation