Skip to content

Commit

Permalink
Stops db_migrate task when rails migration fails
Browse files Browse the repository at this point in the history
  • Loading branch information
EGiataganas committed Aug 11, 2023
1 parent df7fd81 commit 792e091
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/deploy-environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,21 @@ jobs:
env:
CLUSTER: paapi-${{ inputs.environment-name }}
TASK_DEFINITION: paapi-db-migrate-${{ inputs.environment-name }}
LOG_GROUP: paapi-db-migrate-${{ inputs.environment-name }}
PAAPI_SUBNETS: subnet-${{ secrets.PAAPI_SUBNETS }}
PAAPI_SG: sg-${{ secrets.PAAPI_SG }}
run: |
aws ecs run-task --cluster $CLUSTER \
start_time=$(date -Iseconds)
task_arn=$(aws ecs run-task --cluster $CLUSTER \
--task-definition $TASK_DEFINITION --launch-type FARGATE \
--network-configuration '{"awsvpcConfiguration": {"subnets": ["'$PAAPI_SUBNETS'"],"securityGroups": ["'$PAAPI_SG'"],"assignPublicIp": "ENABLED"}}'
--network-configuration '{"awsvpcConfiguration": {"subnets": ["'$PAAPI_SUBNETS'"],"securityGroups": ["'$PAAPI_SG'"],"assignPublicIp": "ENABLED"}}' | \
jq -r '.tasks[].taskArn')
aws ecs wait tasks-stopped --cluster $CLUSTER --tasks "$task_arn"
aws logs tail $LOG_GROUP --format short --since $start_time
result_json=$(aws ecs describe-tasks --cluster $CLUSTER --task $task_arn)
exit_code=$(echo "$result_json" | jq -r '.tasks[].containers[0].exitCode // 1')
if [ $exit_code -gt 0 ]; then echo "$result_json" | jq -r; fi
exit $exit_code
- name: Download task definition for worker high-priority and strip unused properties
env:
Expand Down

0 comments on commit 792e091

Please sign in to comment.