-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRO-610 REFACTOR use ./scripts/deploy_ecs to deploy
- Loading branch information
1 parent
35c28be
commit b1441d5
Showing
2 changed files
with
36 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
CLUSTER_NAME="terrateam-app" | ||
SERVICE_NAME="terrateam-app-service" | ||
IMAGE_NAME="terrat-ee" | ||
GHCR_IMAGE="ghcr.io/${GITHUB_REPOSITORY_OWNER}/${IMAGE_NAME}:${VERSION_TAG}" | ||
|
||
# Fetch the current service information | ||
aws ecs describe-services --cluster "$CLUSTER_NAME" --services "$SERVICE_NAME" > service.json | ||
TASK_DEF_ARN=$(jq -r '.services[0].taskDefinition' service.json) | ||
|
||
# Fetch the current task definition | ||
aws ecs describe-task-definition --task-definition "$TASK_DEF_ARN" > task-def.json | ||
|
||
# Update the app container image | ||
jq --arg newImage "$GHCR_IMAGE" ' | ||
.taskDefinition.containerDefinitions |= map( | ||
if .name == "app" then | ||
.image = $newImage | ||
else | ||
. | ||
end | ||
) | ||
' task-def.json > task-def-updated.json | ||
|
||
# Register the new task definition | ||
NEW_TASK_DEF=$(aws ecs register-task-definition --cli-input-json file://task-def-updated.json) | ||
NEW_TASK_DEF_ARN=$(echo "$NEW_TASK_DEF" | jq -r '.taskDefinition.taskDefinitionArn') | ||
|
||
# Update the service to use the new task definition | ||
aws ecs update-service --cluster "$CLUSTER_NAME" --service "$SERVICE_NAME" --task-definition "$NEW_TASK_DEF_ARN" | ||
|
||
# Wait for the service to stabilize | ||
aws ecs wait services-stable --cluster "$CLUSTER_NAME" --services "$SERVICE_NAME" |