From 9a61298c2e7481a2667ab4cebe03ea8146d979c9 Mon Sep 17 00:00:00 2001 From: belljun3395 <195850@jnu.ac.kr> Date: Wed, 8 Jan 2025 22:43:34 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=A1=EC=85=98=20=ED=83=9C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BB=A4=EB=B0=8B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ecs-dev-cd.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ecs-dev-cd.yml b/.github/workflows/ecs-dev-cd.yml index c1343f851..2cfb10fcf 100644 --- a/.github/workflows/ecs-dev-cd.yml +++ b/.github/workflows/ecs-dev-cd.yml @@ -5,6 +5,7 @@ on: branches: - dev workflow_dispatch: + env: AWS_REGION: ap-northeast-2 ECR_REPOSITORY: few-ecr @@ -67,25 +68,31 @@ jobs: GIT_HASH=$(git rev-parse --short HEAD) ./gradlew buildEcsDockerImage -PimageName=${ECR_REGISTRY}/${ECR_REPOSITORY}:latest docker tag ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH} - docker push ${ECR_REGISTRY}/${ECR_REPOSITORY} --all-tags + docker push ${ECR_REGISTRY}/${ECR_REPOSITORY}:latest + docker push ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH} + - name: Get ECR Repository image path id: get-docker-image-path env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} run: | GIT_HASH=$(git rev-parse --short HEAD) - echo ${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH} - echo "::set-output name=image::${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}" + echo "IMAGE_PATH=${ECR_REGISTRY}/${ECR_REPOSITORY}:${GIT_HASH}" >> $GITHUB_ENV + - name: Download task definition run: | - aws ecs describe-task-definition --task-definition ${TASK_DEFINITION_NAME} --query taskDefinition > task-definition.json + aws ecs describe-task-definition \ + --task-definition ${TASK_DEFINITION_NAME} \ + --query 'taskDefinition' \ + > ${env.ECS_TASK_DEFINITION} + - name: Fill in the new image ID in the Amazon ECS task definition id: task-definition uses: aws-actions/amazon-ecs-render-task-definition@v1 with: task-definition: ${{ env.ECS_TASK_DEFINITION }} container-name: ${{ env.CONTAINER_NAME }} - image: ${{ steps.get-docker-image-path.outputs.image }} + image: ${{ env.IMAGE_PATH }} - name: Deploy Amazon ECS task definition id: ecs-deployment