fix(ci): report migrate run-task failures directly

This commit is contained in:
Adam Moussa 2026-09-25 18:51:30 -04:00
parent 91e8740eca
commit 15e80d56c0
No known key found for this signature in database

View file

@ -216,13 +216,19 @@ jobs:
export NET
SUBNETS="$(python3 -c 'import json,os; print(",".join(json.loads(os.environ["NET"])["subnets"]))')"
SGS="$(python3 -c 'import json,os; print(",".join(json.loads(os.environ["NET"])["securityGroups"]))')"
TASK_ARN="$(aws ecs run-task \
RUN_JSON="$(aws ecs run-task \
--cluster "${CLUSTER}" \
--task-definition "${FAMILY}:${REV}" \
--launch-type FARGATE \
--network-configuration "awsvpcConfiguration={subnets=[${SUBNETS}],securityGroups=[${SGS}],assignPublicIp=ENABLED}" \
--overrides "{\"containerOverrides\":[{\"name\":\"${CONTAINER}\",\"command\":[\"node\",\"packages/api/dist/db/migrate.js\"],\"environment\":[{\"name\":\"DEV_AUTH_BYPASS\",\"value\":\"false\"}]}]}" \
--query 'tasks[0].taskArn' --output text)"
--output json)"
TASK_ARN="$(printf '%s' "${RUN_JSON}" | python3 -c 'import json,sys; data=json.load(sys.stdin); tasks=data.get("tasks") or []; print(tasks[0].get("taskArn") or "" if tasks else "")')"
if [ -z "${TASK_ARN}" ] || [ "${TASK_ARN}" = "None" ]; then
echo "ecs run-task did not start a migrate task" >&2
printf '%s' "${RUN_JSON}" | python3 -c 'import json,sys; data=json.load(sys.stdin); print(json.dumps(data.get("failures") or [], indent=2))' >&2
exit 1
fi
aws ecs wait tasks-stopped --cluster "${CLUSTER}" --tasks "${TASK_ARN}"
EXIT="$(aws ecs describe-tasks --cluster "${CLUSTER}" --tasks "${TASK_ARN}" \
--query 'tasks[0].containers[0].exitCode' --output text)"