refine gitainer deploy to error out if we get err json
All checks were successful
Reload Act Runner Stack to clear cache for workflows / diff (push) Successful in 31s
Reload Act Runner Stack to clear cache for workflows / reload-primary (push) Successful in 5s
Reload Act Runner Stack to clear cache for workflows / wait-for-primary-death (push) Successful in 31s
Reload Act Runner Stack to clear cache for workflows / reload-secondary (push) Successful in 4s
Reload Act Runner Stack to clear cache for workflows / wait-for-secondary-death (push) Successful in 32s
Reload Act Runner Stack to clear cache for workflows / pull-cache-secondary (push) Successful in 1s

This commit is contained in:
Martin Dimitrov 2026-07-07 20:35:06 -07:00
parent ff41fdabf0
commit 6a88a5d1f4

View File

@ -32,12 +32,40 @@ jobs:
run: echo "Workflow successful" run: echo "Workflow successful"
- name: Call Gitainer stack webhooks - name: Call Gitainer stack webhooks
continue-on-error: true continue-on-error: ${{ inputs.delayed_silent }}
run: | run: |
if [ "${{ inputs.delayed_silent }}" = "true" ]; then if [ "${{ inputs.delayed_silent }}" = "true" ]; then
echo "Delaying the webhook call by 10s using a detached container." echo "Delaying the webhook call by 10s using a detached container."
echo "This gives the runner time to report job completion and clean up before it restarts." echo "This gives the runner time to report job completion and clean up before it restarts."
docker run --rm -d alpine sh -c "apk add --no-cache curl && sleep 10 && curl --max-time ${{ inputs.webhook_timeout }} --request POST 'http://gitainer.local.chromart.cc/api/stacks/${{ inputs.stack_name }}?pretty'" docker run --rm -d alpine sh -c "apk add --no-cache curl && sleep 10 && curl --max-time ${{ inputs.webhook_timeout }} --request POST 'http://gitainer.local.chromart.cc/api/stacks/${{ inputs.stack_name }}?pretty'"
else else
curl --max-time ${{ inputs.webhook_timeout }} --request POST "http://gitainer.local.chromart.cc/api/stacks/${{ inputs.stack_name }}?pretty" if ! RESPONSE=$(curl --max-time ${{ inputs.webhook_timeout }} \
--write-out "\n%{http_code}" \
--silent \
--show-error \
--request POST \
"http://gitainer.local.chromart.cc/api/stacks/${{ inputs.stack_name }}?pretty"); then
echo "Error: curl command failed."
exit 1
fi
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
echo "HTTP Status Code: $HTTP_CODE"
echo "Response Body:"
echo "$RESPONSE_BODY"
if echo "$RESPONSE_BODY" | jq -e . >/dev/null 2>&1; then
if echo "$RESPONSE_BODY" | jq -e '(.err != null and .err != false) or (.error != null and .error != false)' >/dev/null 2>&1; then
ERR_MSG=$(echo "$RESPONSE_BODY" | jq -r 'if .err != null and .err != false then .err else .error end')
echo "Error: Gitainer deploy failed with message: $ERR_MSG"
exit 1
fi
fi
if [ "$HTTP_CODE" -ne 200 ]; then
echo "Error: Gitainer deploy failed with HTTP status code $HTTP_CODE"
exit 1
fi
fi fi