From 10da7e73c67c513dc8433c1b789cb005f8ccedad Mon Sep 17 00:00:00 2001 From: JuseungL Date: Tue, 26 Nov 2024 12:22:35 +0900 Subject: [PATCH] first commit --- .github/workflows/deploy.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 8374d12..f0e0fcd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -62,12 +62,17 @@ jobs: id: build-image env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }} run: | + # 현재 날짜와 시간으로 태그 생성 (예: 2024-11-26_14-30-00) + IMAGE_TAG=$(date +'%Y-%m-%d_%H-%M-%S') + echo "IMAGE_TAG=$IMAGE_TAG" >> $GITHUB_ENV # 환경 변수에 IMAGE_TAG 저장 + + # Docker 이미지를 빌드하고 푸시 docker build --build-arg JAR_FILE=build/libs/*.jar -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG echo "IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_ENV + # $GITHUB_ENV : 작업(Job) 내 모든 스텝에서 사용 가능 - $VARIABLE 환경 변수로 직접 참조 # $GITHUB_OUTPUT : 특정 스텝에서만 설정한 출력값 전달 가능 - steps..outputs.로 참조 @@ -76,18 +81,18 @@ jobs: run: | aws ecs describe-task-definition --task-definition ${{ env.ECS_TASK_DEFINITION }} --query taskDefinition > task-definition.json - # Fill in the new image ID in the Amazon ECS task definition + # Fill in the new image ID in the Amazon ECS task definition (v3) - name: Fill in the new image ID in the ECS task definition id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 + uses: aws-actions/amazon-ecs-render-task-definition@v3 with: task-definition: task-definition.json container-name: ${{ env.CONTAINER_NAME }} image: ${{ env.IMAGE }} - # Deploy the updated ECS task definition + # Deploy the updated ECS task definition (v3) - name: Deploy ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + uses: aws-actions/amazon-ecs-deploy-task-definition@v3 with: task-definition: ${{ steps.task-def.outputs.task-definition }} service: ${{ env.ECS_SERVICE }}