12 October 2026 · 6 MIN READ
Deploying to ECS with GitHub Actions, from a commit to a running service
How a commit becomes a running ECS service: checks first, one image per commit, and deployment logic that treats each environment differently.
One image per commit
The single most useful habit in container delivery is tagging every image with the commit SHA that produced it. Not “latest”, not the branch name — the exact SHA.
When something breaks at 11pm, the question that matters is “what is actually running?” A SHA tag answers it in seconds, and it is the same answer you get from git. A mutable tag forces you to guess.
# Build once, tag by commit
docker build --platform linux/amd64 -t app:${GITHUB_SHA} .
# Push the same image to ECR
docker tag app:${GITHUB_SHA} $ECR_REPO:${GITHUB_SHA}
docker push $ECR_REPO:${GITHUB_SHA}Checks before packaging
A pipeline should refuse to build an image of code that does not pass its own checks. Formatting, linting, type checks, builds, and tests run before the Docker build ever starts.
One detail that pays for itself: running the test suite against a PostgreSQL service container, so the checks exercise the same database engine production uses instead of a convenient stand-in.
on: [push, pull_request]
concurrency:
group: checks-${{ github.ref }}
cancel-in-progress: true
jobs:
checks:
services:
postgres:
image: postgres:16
# pnpm lint, type checks, build, pnpm testEnvironments are configuration, not code
Dev, demo, and production should run the same image. What differs — task definition sizes, environment variables, secrets, autoscaling — belongs in per-environment configuration that is explicit and reviewable.
The same SHA can be promoted from dev to demo to production. If an environment needs a different image tag for any reason other than a staged rollout, the pipeline is hiding a real difference.
Verify after the deployment
A green deploy step is not the finish line. The release is verified when the application answers: health checks pass, the service settles to the desired count, and CloudWatch shows the new revision serving traffic.
Watch the rollout, check the logs for the first minute, and make the verification a named step in the workflow rather than an assumption in someone’s head.
- Health check on the new revision before declaring success.
- Watch the service events while the deployment settles.
- Keep CloudWatch alarms visible next to the pipeline, not in another tab.
Three gotchas worth avoiding
Small things that have cost me time:
- Building on an Apple Silicon Mac without --platform linux/amd64, which produces an image the Lambda runtime rejects.
- Letting concurrent pushes fight over the same ECS service — a concurrency group on the deploy job fixes it.
- Secrets pasted inline into a workflow. Use GitHub Environments with secrets scoped per environment instead.