Skip to content

Commit a726d87

Browse files
committed
Update deploy to ecs template config
1 parent 4d73fc2 commit a726d87

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

priv/templates/nimble_template/.github/workflows/deploy_to_aws_ecs.yml.eex

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ on:
99
env:
1010
ECS_CLUSTER: ${{ secrets.ECS_CLUSTER }}
1111
ECS_SERVICE: ${{ secrets.ECS_SERVICE }}
12+
ECS_TASK_DEFINITION: ${{ secrets.ECS_TASK_DEFINITION }}
13+
ECS_CONTAINER_NAME: ${{ secrets.ECS_CONTAINER_NAME }}
14+
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
1215

1316
jobs:
1417
deploy:
@@ -38,15 +41,34 @@ jobs:
3841
id: build-image
3942
env:
4043
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
41-
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY_NAME }}
44+
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
4245
IMAGE_TAG: ${{ github.sha }}
4346
run: |
4447
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
4548
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
49+
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
4650

4751
- name: Log out of Amazon ECR
4852
if: always()
4953
run: docker logout ${{ steps.login-ecr.outputs.registry }}
5054

51-
- name: Update Service
52-
run: aws ecs update-service --cluster $ECS_CLUSTER --service $ECS_SERVICE --force-new-deployment
55+
- name: Download task definition
56+
run: |
57+
aws ecs describe-task-definition --task-definition ${{ env.ECS_TASK_DEFINITION }} \
58+
--query taskDefinition > task-definition.json
59+
60+
- name: Fill in the new image ID in the Amazon ECS task definition
61+
id: task-def
62+
uses: aws-actions/amazon-ecs-render-task-definition@97587c9d45a4930bf0e3da8dd2feb2a463cf4a3a
63+
with:
64+
task-definition: task-definition.json
65+
container-name: ${{ env.ECS_CONTAINER_NAME }}
66+
image: ${{ steps.build-image.outputs.image }}
67+
68+
- name: Deploy Amazon ECS task definition
69+
uses: aws-actions/amazon-ecs-deploy-task-definition@100cd113ebe287f1550436363834e6f2b2b4c16f
70+
with:
71+
task-definition: ${{ steps.task-def.outputs.task-definition }}
72+
service: ${{ env.ECS_SERVICE }}
73+
cluster: ${{ env.ECS_CLUSTER }}
74+
wait-for-service-stability: true

0 commit comments

Comments
 (0)