Skip to content

Commit

Permalink
ECR to ECS
Browse files Browse the repository at this point in the history
  • Loading branch information
forkimenjeckayang committed Jun 20, 2024
1 parent 77b5742 commit 5518443
Showing 1 changed file with 1 addition and 83 deletions.
84 changes: 1 addition & 83 deletions .github/workflows/create_ECR_deploy_to_ECS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,86 +83,4 @@ jobs:
with:
task-definition: ${{ steps.task-def.outputs['task-definition'] }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}



# - name: Update ECS service with new image
# run: |
# IMAGE="${{ env.IMAGE }}"

# # Fetch the current task definition
# CURRENT_TASK_DEF=$(aws ecs describe-task-definition --task-definition ${{ env.ECS_TASK_DEFINITION }} --query 'taskDefinition' --output json)

# # Debug: Output current task definition to log
# echo "Current task definition: $CURRENT_TASK_DEF"

# # Extract the task definition family
# FAMILY=$(echo $CURRENT_TASK_DEF | jq -r '.family')

# # Get the container definitions and update the image
# UPDATED_CONTAINER_DEFINITIONS=$(echo $CURRENT_TASK_DEF | jq --arg IMAGE "$IMAGE" --arg NAME "${{ env.CONTAINER_NAME }}" '.containerDefinitions | map(if .name == $NAME then .image = $IMAGE else . end)')

# # Debug: Output updated container definitions to log
# echo "Updated container definitions: $UPDATED_CONTAINER_DEFINITIONS"

# # Create a temporary JSON file with updated container definitions
# echo "$UPDATED_CONTAINER_DEFINITIONS" > updated-containers.json

# # Debug: Check if the file exists and output its contents
# ls -l updated-containers.json
# cat updated-containers.json

# # Register the new task definition revision
# NEW_TASK_DEF_ARN=$(aws ecs register-task-definition \
# --family $FAMILY \
# --task-role-arn "$(echo $CURRENT_TASK_DEF | jq -r '.taskRoleArn')" \
# --execution-role-arn "$(echo $CURRENT_TASK_DEF | jq -r '.executionRoleArn')" \
# --network-mode "$(echo $CURRENT_TASK_DEF | jq -r '.networkMode')" \
# --container-definitions file://updated-containers.json \
# --volumes "$(echo $CURRENT_TASK_DEF | jq -c '.volumes')" \
# --placement-constraints "$(echo $CURRENT_TASK_DEF | jq -c '.placementConstraints')" \
# --requires-compatibilities "$(echo $CURRENT_TASK_DEF | jq -c '.requiresCompatibilities')" \
# --cpu "$(echo $CURRENT_TASK_DEF | jq -r '.cpu')" \
# --memory "$(echo $CURRENT_TASK_DEF | jq -r '.memory')" \
# --tags "$(echo $CURRENT_TASK_DEF | jq -c '.tags')" \
# --pid-mode "$(echo $CURRENT_TASK_DEF | jq -r '.pidMode')" \
# --ipc-mode "$(echo $CURRENT_TASK_DEF | jq -r '.ipcMode')" \
# --proxy-configuration "$(echo $CURRENT_TASK_DEF | jq -c '.proxyConfiguration')" \
# --inference-accelerators "$(echo $CURRENT_TASK_DEF | jq -c '.inferenceAccelerators')" \
# --ephemeral-storage "$(echo $CURRENT_TASK_DEF | jq -c '.ephemeralStorage')" \
# --runtime-platform "$(echo $CURRENT_TASK_DEF | jq -c '.runtimePlatform')" \
# --query 'taskDefinition.taskDefinitionArn' \
# --output text)

# # Update ECS service to use the new task definition revision
# aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --task-definition $NEW_TASK_DEF_ARN
# aws ecs wait services-stable --cluster ${{ env.ECS_CLUSTER }} --services ${{ env.ECS_SERVICE }}

# - name: Get current task definition
# id: get-task-def
# run: |
# aws ecs describe-task-definition --task-definition ${{ env.ECS_TASK_DEFINITION }} > current-task-def.json

# - name: Update task definition with new image
# id: update-task-def
# run: |
# NEW_IMAGE="${{ env.IMAGE }}"
# CONTAINER_NAME="${{ env.CONTAINER_NAME }}"
# jq --arg IMAGE "$NEW_IMAGE" --arg NAME "$CONTAINER_NAME" \
# '.taskDefinition.containerDefinitions |= map(if .name == $NAME then .image = $IMAGE else . end)' \
# current-task-def.json > updated-task-def.json

# - name: Register updated task definition
# id: register-task-def
# run: |
# aws ecs register-task-definition \
# --cli-input-json file://updated-task-def.json \
# --query 'taskDefinition.taskDefinitionArn' \
# --output text > task-def-arn.txt
# echo "TASK_DEF_ARN=$(cat task-def-arn.txt)" >> $GITHUB_ENV

# - name: Deploy updated task definition
# run: |
# aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --task-definition ${{ env.TASK_DEF_ARN }}
# aws ecs wait services-stable --cluster ${{ env.ECS_CLUSTER }} --services ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}

0 comments on commit 5518443

Please sign in to comment.