Zero-Downtime Deploys on AWS ECS with GitHub Actions (Blue/Green)
The exact pipeline I use: migrations without locks, health-checked deregistration, automated rollback on p99 regression.
# expand-contract migrate pattern
- run: php artisan migrate --force # additive only
- uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
wait-for-service-stability: true
codedeploy-appspec: appspec.yamlDeployments should be boring
If deploys feel scary, the pipeline is missing guardrails. My standard: additive-only migrations (expand then contract), ECS blue/green with CodeDeploy, ALB health checks with deregistration delay, and automatic rollback when error rate or p99 breaches for 5 minutes.
GitHub Actions runs test → build → push → migrate → shift 10% traffic → bake 5 min → shift 100%. Total cycle: ~9 minutes, multiple times a day.
Migration discipline
Never rename/drop a column in one deploy. Step 1: add new column, dual-write. Step 2: backfill. Step 3 (next release): switch reads, drop old. This single rule eliminates 80% of deploy outages I have seen.
verifiedKey takeaways
- arrow_rightAdditive migrations + blue/green = calm deploys.
- arrow_rightCanary 10% with auto-rollback on SLO burn.
- arrow_rightDeregistration delay matters more than you think.