@@ -55,13 +55,34 @@ jobs:
5555 id : build-image
5656 env :
5757 ECR_REPOSITORY : captioning-service
58+ IMAGE_TAG : ${{ github.sha }}
5859 run : |
59- docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./captioning-service
60- docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
60+ docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./captioning-service
61+ docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
62+ echo "::set-output name=image::${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}"
6163
62- - name : Update Amazon ECS service
64+ - name : Download task definition
65+ id : task-def
6366 run : |
64- aws ecs update-service --cluster ai-services-cluster --service captioning-service --force-new-deployment --region ${{ env.AWS_REGION }}
67+ aws ecs describe-task-definition --task-definition captioning-service --query taskDefinition > task-definition.json
68+
69+ - name : Fill in the new image ID in the Amazon ECS task definition
70+ id : render-task-def
71+ uses : aws-actions/amazon-ecs-render-task-definition@v1
72+ with :
73+ task-definition : task-definition.json
74+ container-name : captioning-service # Task Definition에 정의된 컨테이너 이름
75+ image : ${{ steps.build-image.outputs.image }}
76+
77+
78+ - name : Deploy Amazon ECS task definition
79+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
80+ with :
81+ task-definition : ${{ steps.render-task-def.outputs.task-definition }}
82+ service : captioning-service # 업데이트할 서비스 이름
83+ cluster : ai-services-cluster # 클러스터 이름
84+ wait-for-service-stability : true # 배포가 안정될 때까지 기다림
85+
6586
6687 deploy-classifying :
6788 name : Deploy Classifying Service
@@ -87,13 +108,32 @@ jobs:
87108 id : build-image
88109 env :
89110 ECR_REPOSITORY : classifying-service
111+ IMAGE_TAG : ${{ github.sha }}
90112 run : |
91- docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./classifying-service
92- docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
113+ docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./classifying-service
114+ docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
93115
94- - name : Update Amazon ECS service
116+ - name : Download task definition
117+ id : task-def
95118 run : |
96- aws ecs update-service --cluster ai-services-cluster --service classifying-service --force-new-deployment --region ${{ env.AWS_REGION }}
119+ aws ecs describe-task-definition --task-definition classifying-service --query taskDefinition > task-definition.json
120+
121+ - name : Fill in the new image ID in the Amazon ECS task definition
122+ id : render-task-def
123+ uses : aws-actions/amazon-ecs-render-task-definition@v1
124+ with :
125+ task-definition : task-definition.json
126+ container-name : classifying-service # Task Definition에 정의된 컨테이너 이름
127+ image : ${{ steps.build-image.outputs.image }}
128+
129+
130+ - name : Deploy Amazon ECS task definition
131+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
132+ with :
133+ task-definition : ${{ steps.render-task-def.outputs.task-definition }}
134+ service : classifying-service # 업데이트할 서비스 이름
135+ cluster : ai-services-cluster # 클러스터 이름
136+ wait-for-service-stability : true # 배포가 안정될 때까지 기다림
97137
98138 deploy-masking :
99139 name : Deploy Masking Service
@@ -119,10 +159,29 @@ jobs:
119159 id : build-image
120160 env :
121161 ECR_REPOSITORY : masking-service
162+ IMAGE_TAG : ${{ github.sha }}
122163 run : |
123- docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest ./masking-service
124- docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
164+ docker build -t ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ./masking-service
165+ docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }}
125166
126- - name : Update Amazon ECS service
167+ - name : Download task definition
168+ id : task-def
127169 run : |
128- aws ecs update-service --cluster ai-services-cluster --service masking-service --force-new-deployment --region ${{ env.AWS_REGION }}
170+ aws ecs describe-task-definition --task-definition masking-service --query taskDefinition > task-definition.json
171+
172+ - name : Fill in the new image ID in the Amazon ECS task definition
173+ id : render-task-def
174+ uses : aws-actions/amazon-ecs-render-task-definition@v1
175+ with :
176+ task-definition : task-definition.json
177+ container-name : masking-service # Task Definition에 정의된 컨테이너 이름
178+ image : ${{ steps.build-image.outputs.image }}
179+
180+
181+ - name : Deploy Amazon ECS task definition
182+ uses : aws-actions/amazon-ecs-deploy-task-definition@v1
183+ with :
184+ task-definition : ${{ steps.render-task-def.outputs.task-definition }}
185+ service : masking-service # 업데이트할 서비스 이름
186+ cluster : ai-services-cluster # 클러스터 이름
187+ wait-for-service-stability : true # 배포가 안정될 때까지 기다림
0 commit comments