Skip to content

Commit

Permalink
PRO-610 REFACTOR use ecr image for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
bender2352 committed Nov 20, 2024
1 parent 815b840 commit 31585f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ jobs:
TERRATEAM_ENVIRONMENT: ${{ inputs.environment }}
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
MATRIX_PASSWORD: ${{ secrets.MATRIX_PASSWORD }}
AWS_ACCOUNT_NUMBER: ${{ secrets.AWS_ACCOUNT_NUMBER }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}

permissions:
contents: read
Expand Down
13 changes: 12 additions & 1 deletion scripts/deploy_ecs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,17 @@ CLUSTER_NAME="terrateam-app"
SERVICE_NAME="terrateam-app-service"
IMAGE_NAME="terrat-ee"
GHCR_IMAGE="ghcr.io/${GITHUB_REPOSITORY_OWNER}/${IMAGE_NAME}:${VERSION_TAG}"
ECR_REPO_NAME="terrat-ee"
ECR_IMAGE="${AWS_ACCOUNT_NUMBER}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com/${ECR_REPO_NAME}:${VERSION_TAG}"

# Authenticate Docker to ECR
aws ecr get-login-password --region "$AWS_DEFAULT_REGION" | docker login --username AWS --password-stdin "${AWS_ACCOUNT_NUMBER}.dkr.ecr.${AWS_DEFAULT_REGION}.amazonaws.com"

# Tag the image for ECR
docker tag "$GHCR_IMAGE" "$ECR_IMAGE"

# Push the image to ECR
docker push "$ECR_IMAGE"

# Fetch the current service information
aws ecs describe-services --cluster "$CLUSTER_NAME" --services "$SERVICE_NAME" > service.json
Expand All @@ -16,7 +27,7 @@ TASK_DEF_ARN=$(jq -r '.services[0].taskDefinition' service.json)
aws ecs describe-task-definition --task-definition "$TASK_DEF_ARN" > task-def.json

# Create the new task definition JSON
jq --arg newImage "$GHCR_IMAGE" '
jq --arg newImage "$ECR_IMAGE" '
.taskDefinition |
.containerDefinitions |= map(
if .name == "app" then
Expand Down

0 comments on commit 31585f1

Please sign in to comment.