publish.sh: address review — fix PR-failure format, capture HTTP status, append activity to push failure
This commit is contained in:
@@ -334,13 +334,12 @@ if [ -n "$(git status --porcelain)" ]; then
|
|||||||
git add -A
|
git add -A
|
||||||
git commit -m "@$NAME: issue #$NUM"
|
git commit -m "@$NAME: issue #$NUM"
|
||||||
fi
|
fi
|
||||||
push_ok=0
|
|
||||||
if git push origin "HEAD:$BRANCH"; then
|
if git push origin "HEAD:$BRANCH"; then
|
||||||
push_ok=1
|
:
|
||||||
else
|
else
|
||||||
status=$?
|
status=$?
|
||||||
echo "git push failed for $BRANCH (exit $status)"
|
echo "git push failed for $BRANCH (exit $status)"
|
||||||
post "$(printf '⚠️ Push to branch `%s` failed (git exit %s). The PR will not open until the push succeeds. Please check the Actions log.' "$BRANCH" "$status")"
|
post "$(printf '⚠️ Push to branch `%s` failed (git exit %s). The PR will not open until the push succeeds. Please check the Actions log.%s' "$BRANCH" "$status" "$activity")"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
git fetch -q origin 2>/dev/null || true
|
git fetch -q origin 2>/dev/null || true
|
||||||
@@ -368,17 +367,19 @@ url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
|||||||
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
||||||
if [ -z "$url" ]; then
|
if [ -z "$url" ]; then
|
||||||
title="@$NAME: $TITLE"
|
title="@$NAME: $TITLE"
|
||||||
resp=$(curl -sS -X POST "${hdr[@]}" "$API/pulls" \
|
resp_body=/tmp/pr_create_resp.json
|
||||||
|
http_status=$(curl -sS -o "$resp_body" -w '%{http_code}' -X POST "${hdr[@]}" "$API/pulls" \
|
||||||
-d "$(jq -nc --arg t "$title" --arg h "$br" --arg b "$prbody" \
|
-d "$(jq -nc --arg t "$title" --arg h "$br" --arg b "$prbody" \
|
||||||
'{title:$t, head:$h, base:"main", body:$b}')")
|
'{title:$t, head:$h, base:"main", body:$b}')")
|
||||||
echo "PR create ($br): $resp"
|
resp=$(cat "$resp_body" 2>/dev/null || true)
|
||||||
|
echo "PR create ($br): HTTP $http_status — $resp"
|
||||||
url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null)
|
||||||
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null)
|
||||||
fi
|
fi
|
||||||
if [ -z "$url" ]; then
|
if [ -z "$url" ]; then
|
||||||
err_msg=$(printf '%s' "$resp" | jq -r 'if type=="object" and .message then .message else "(no error message in response)" end' 2>/dev/null)
|
err_msg=$(printf '%s' "$resp" | jq -r 'if type=="object" and .message then .message else "(no error message in response)" end' 2>/dev/null)
|
||||||
echo "PR open/lookup failed for $br — response: $resp"
|
echo "PR open/lookup failed for $br — HTTP $http_status — response: $resp"
|
||||||
post "$(printf '⚠️ Failed to open PR for branch `%s`.%s\n\nGitea message: %s' "$br" "$activity" "$err_msg")"
|
post "$(printf '⚠️ Failed to open PR for branch `%s`.\n\nHTTP status: %s\nGitea message: %s%s' "$br" "$http_status" "$err_msg" "$activity")"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user