From 2ebf06bc72812c099c7c34f8f82186e4af1938dc Mon Sep 17 00:00:00 2001 From: Priyanka-Inflectionzone Date: Fri, 2 Feb 2024 16:24:27 +0530 Subject: [PATCH] created new revision for task definition --- .github/workflows/deploy-ci-cd.yml | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/deploy-ci-cd.yml b/.github/workflows/deploy-ci-cd.yml index c6b370de7..b4df9342a 100644 --- a/.github/workflows/deploy-ci-cd.yml +++ b/.github/workflows/deploy-ci-cd.yml @@ -52,15 +52,27 @@ jobs: run: | aws ecs describe-task-definition --task-definition reancare-service:${{ steps.get-latest-revision.outputs.revision }} \ --query taskDefinition > task-definition.json + cat task-definition.json - - name: New image ID in the Amazon ECS task definition - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: task-definition.json - container-name: reancare-container - image: 443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }} - revision: ${{ steps.get-latest-revision.outputs.revision }} + - name: Update container image in task definition + run: | + jq '.containerDefinitions[0].image="443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${GITHUB_SHA}"' task-definition.json > new-task-definition.json + + + # - name: New image ID in the Amazon ECS task definition + # id: task-def + # uses: aws-actions/amazon-ecs-render-task-definition@v1 + # with: + # task-definition: task-definition.json + # container-name: reancare-container + # image: 443751504066.dkr.ecr.ap-south-1.amazonaws.com/reancare:${{ github.sha }} + + - name: Create a new revision of ECS task definition + id: create-new-revision + run: | + new_revision=$(aws ecs register-task-definition --cli-input-json file://new-task-definition.json --query 'taskDefinition.revision' --output text) + echo "New revision created: $new_revision" + echo "::set-output name=new-revision::$new_revision" - name: Task Definition Variable id: taskdefintionvar @@ -70,4 +82,4 @@ jobs: - name: Deploy to ECS run: | - aws ecs update-service --cluster reancare-cluster --service rean-backend --task-definition reancare-service:${{ steps.get-latest-revision.outputs.revision }} --force-new-deployment + aws ecs update-service --cluster reancare-cluster --service rean-backend --task-definition reancare-service:${{ steps.create-new-revision.outputs.new-revision }} --force-new-deployment