Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JuseungL committed Nov 26, 2024
1 parent 815976b commit 10da7e7
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.<step_id>.outputs.<name>로 참조

Expand All @@ -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 }}
Expand Down

0 comments on commit 10da7e7

Please sign in to comment.