From ae1c193a3f7bdd99b1e1986b2d6bc3afeea84880 Mon Sep 17 00:00:00 2001 From: him-bhutani7 Date: Wed, 17 Jan 2024 14:34:01 +0530 Subject: [PATCH] fix: actions deployment --- .github/workflows/build-deploy-prod.yml | 59 ++++++++++++------------- 1 file changed, 29 insertions(+), 30 deletions(-) diff --git a/.github/workflows/build-deploy-prod.yml b/.github/workflows/build-deploy-prod.yml index 629bb05..afabcd9 100644 --- a/.github/workflows/build-deploy-prod.yml +++ b/.github/workflows/build-deploy-prod.yml @@ -32,9 +32,9 @@ jobs: - name: checkout uses: actions/checkout@v2 - # - name: Set output - # id: vars - # run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + - name: Set output + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 @@ -44,33 +44,32 @@ jobs: role-session-name: GithubActions # gather metadata from git & github actions to reference in docker - # - name: git & github metadata - # id: metadata - # uses: docker/metadata-action@v3 - # with: - # images: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.AWS_ECR_REPO }} + - name: git & github metadata + id: metadata + uses: docker/metadata-action@v3 + with: + images: ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.AWS_ECR_REPO }} - # # login in docker repository - # - name: docker login - # uses: aws-actions/amazon-ecr-login@v1 + # login in docker repository + - name: docker login + uses: aws-actions/amazon-ecr-login@v1 - # # build a docker image - # - name: docker & push image - # uses: docker/build-push-action@v2 - # with: - # context: . - # file: ./Dockerfile - # push: true - # tags: | - # ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:latest - # ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ steps.vars.outputs.tag }} + # build a docker image + - name: docker & push image + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + push: true + tags: | + ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:latest + ${{ env.AWS_ACCOUNT_ID }}.dkr.ecr.${{ env.AWS_REGION }}.amazonaws.com/${{ env.ECR_REPO }}:${{ steps.vars.outputs.tag }} - # # deploy to AWS ECS - # - name: Deploy to Amazon ECS - # uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - # with: - # task-definition: infra/aws-ecs/task_definition_${{ env.ENVIRONMENT }}.json - # service: ${{ env.ECS_SERVICE }} - # cluster: ${{ env.ECS_CLUSTER }} - # wait-for-service-stability: true - + # deploy to AWS ECS + - name: Deploy to Amazon ECS + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: infra/aws-ecs/task_definition_${{ env.ENVIRONMENT }}.json + service: ${{ env.ECS_SERVICE }} + cluster: ${{ env.ECS_CLUSTER }} + wait-for-service-stability: true