-
Notifications
You must be signed in to change notification settings - Fork 10
fix(ci): update ECS task definition with new image before deployment #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The previous deployment workflow only called force-new-deployment which restarts tasks using the current task definition. If the task definition has a pinned image tag, ECS would pull the old image. This fix: 1. Gets the current task definition from the ECS service 2. Updates it with the new image (using commit SHA tag) 3. Registers a new task definition revision 4. Deploys the service with the new task definition This ensures each deployment uses the freshly built Docker image.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a critical deployment issue where ECS deployments were reusing old Docker images instead of deploying newly built ones. The root cause was that update-service --force-new-deployment only restarts tasks using the current task definition, which had a pinned image tag. The fix updates the task definition with the new image SHA before deploying.
- Updates the deployment flow to retrieve the current task definition, update it with the new commit-tagged image, register a new revision, and then deploy
- Applies the same fix to both staging and production workflows
- Standardizes quote styles throughout the workflow files from single to double quotes
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
| .github/workflows/docker-stg.yaml | Replaces simple force-new-deployment with full task definition update flow for staging; standardizes quotes |
| .github/workflows/docker-prod.yaml | Applies the same task definition update logic to production deployments |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Fix integer comparison: remove quotes around 0 in -eq comparison - Add TASK_DEF_ARN validation after describe-services call - Add error handling for describe-task-definition command - Add JSON validation for task definition output - Add NEW_TASK_DEF_ARN validation after register-task-definition - Consistent whitespace formatting across both workflow files
| NEW_IMAGE="${REGISTRY}/contracts-ui-builder-stg:${{ github.sha }}" | ||
| echo "Target image: $NEW_IMAGE" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be tagged always with github.sha and also latest...for staging atleast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both tags are already pushed in the build step (lines 189-190 and 222-223). The deploy intentionally uses the SHA tag for deterministic, traceable deployments
Reverts the complex task definition update logic from PR #294. The simple --force-new-deployment is sufficient since the task definition uses :latest tag.
…295) * revert(ci): restore simple ECS force-new-deployment Reverts the complex task definition update logic from PR #294. The simple --force-new-deployment is sufficient since the task definition uses :latest tag. * fix(builder): scan both node_modules locations for Tailwind classes In Docker builds, .npmrc is excluded via .dockerignore, so pnpm's shamefully-hoist=true doesn't apply. Packages install in packages/builder/node_modules/ instead of root. Now scans both locations: - Root node_modules (local dev with shameful hoisting) - Builder's node_modules (Docker builds without .npmrc)
Summary
Fix ECS deployments to actually deploy new Docker images instead of reusing old ones.
Problem
The staging deployment has been showing old CSS styling for hours despite multiple successful builds. Investigation revealed:
aws ecs update-service --force-new-deployment:latestSolution
Update the deploy job to:
This ensures each deployment uses the freshly built Docker image from that specific commit.
Changes
docker-stg.yamldeploy job with proper task definition update flowdocker-prod.yamlwith the same fixTesting
After merging, trigger the staging workflow to verify the new deployment properly updates the Docker image.