File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,24 @@ echo "::endgroup::"
6161echo " ::group::Apply Kubernetes Job"
6262kubectl apply --filename $KUBERNETES_DEPLOYMENT_REPO_PATH /infrastructure/$ENVIRONMENT_NAME /job/$KUBERNETES_DEPLOYMENT_NAME -migrate.yml
6363echo " Waiting for migration job to complete ..."
64- kubectl wait --for=condition=complete --timeout 60s job/$KUBERNETES_DEPLOYMENT_NAME -migrate
64+
65+ set +e
66+ # wait for completion as background process - capture PID
67+ kubectl wait --for=condition=complete --timeout 60s job/$KUBERNETES_DEPLOYMENT_NAME -migrate &
68+ completion_pid=$!
69+
70+ # wait for failure as background process - capture PID
71+ kubectl wait --for=condition=failed --timeout 60s job/$KUBERNETES_DEPLOYMENT_NAME -migrate && exit 1 &
72+ failure_pid=$!
73+
74+ # capture exit code of the first subprocess to exit
75+ wait -n $completion_pid $failure_pid
76+
77+ # store exit code in variable
78+ exit_code=$?
79+
80+ set -e
81+
6582kubectl logs job/$KUBERNETES_DEPLOYMENT_NAME -migrate
6683kubectl delete job/$KUBERNETES_DEPLOYMENT_NAME -migrate
6784echo " ::endgroup::"
@@ -71,4 +88,6 @@ echo "::group::Get Alembic upgraded revision"
7188ALEMBIC_UPGRADED_REV=$( kubectl exec -i deployment/${KUBERNETES_DEPLOYMENT_NAME} -- alembic current 2> /dev/null || true)
7289echo " ALEMBIC_UPGRADED_REV=${ALEMBIC_UPGRADED_REV: 0: 12} " >> $GITHUB_OUTPUT
7390echo " Alembic upgraded revision: $ALEMBIC_UPGRADED_REV "
74- echo " ::endgroup::"
91+ echo " ::endgroup::"
92+
93+ exit $exit_code
You can’t perform that action at this time.
0 commit comments