name: Continuous Deployment
on: workflow_call:
jobs: ECS: runs-on: ubuntu-latest
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.CHAVEDEACESSO }}
aws-secret-access-key: ${{ secrets.CHAVEDEACESSOSSECRETA }}
aws-region: us-east-2
- name: Fetch ECS task definition
run: aws ecs describe-task-definition --task-definition tarefa-api-go:1 --query taskDefinition > task-definition.json
- name: copia do task-definition
run: cp task-definition.json task-definition.json.old
- name: Debug Task Definition
run: cat task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
continue-on-error: true
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: API Go Dev
image: vitorgrisolia/go_ci:${{ github.run_number }}
environment-variables: |
HOST=${{ secrets.DBHOST }}
USER=${{ secrets.DBUSER }}
PASSWORD=${{ secrets.DBPASSWORD }}
DBNAME=${{ secrets.DBNAME }}
DBPORT=${{ secrets.DBPORT }}
PORT=8000
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: Servico_API_GO
cluster: API-Go-cluster
wait-for-service-stability: true
- name: Requisição
continue-on-error: true
run: echo "REQUEST=0" >> $GITHUB_ENV; sleep 30s; wget LB-API-Go-288851699.us-east-2.elb.amazonaws.com:8000/vitor || echo "REQUEST=1" >> $GITHUB_ENV
- name: Deploy Amazon ECS task definition
if: ${{ env.REQUEST != 0 }}
continue-on-error: true
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
with:
task-definition: task-definition.json.old
service: Servico_API_GO
cluster: API-Go-cluster
wait-for-service-stability: true