Last active
June 21, 2024 16:58
-
-
Save mesaque/e6bc0cceac94b6f201d0a7581c269380 to your computer and use it in GitHub Desktop.
AWS ECS: Script for creating a new revision of a task definition and update a service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: Setup of aws-cli | |
if: github.ref == 'refs/heads/master' | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-region: us-east-1 | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: deploy to PRODUCTION | |
if: github.ref == 'refs/heads/master' | |
run: | | |
aws ecs describe-task-definition --task-definition ${{ env.TASK_FAMILY }} --region=us-east-1 > /tmp/taskDefinition.json | |
newContainerDefinitions=$(jq '.taskDefinition.containerDefinitions[] | .image = "'${{ env.ECR_URI }}:${{ env.IMAGE_TAG }}'"' /tmp/taskDefinition.json) | |
taskDefinitionMemory=$(jq -r '.taskDefinition.memory ' /tmp/taskDefinition.json) | |
taskDefinitionCPU=$(jq -r '.taskDefinition.cpu ' /tmp/taskDefinition.json) | |
aws ecs register-task-definition --family ${{ TASK_FAMILY }} --container-definitions "$newContainerDefinitions" --memory "$taskDefinitionMemory" --cpu "$taskDefinitionCPU" --network-mode ${{ env.NETWORKMODE }} --requires-compatibilities "FARGATE" --execution-role-arn "${{ env.ROLEARN }}" > /tmp/resultTaskDefinition.json | |
newtaskDefinitionRevision=$(jq -r '.taskDefinition.revision' /tmp/resultTaskDefinition.json) | |
aws ecs update-service --cluster ${{ env.CLUSTER_NAME }} --service ${{ env.SERVICE_NAME }} --task-definition loggi:${newtaskDefinitionRevision} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment