From c4fb117b931b823ab0298e9d2e8c5d6609309909 Mon Sep 17 00:00:00 2001 From: junior Date: Mon, 27 Jul 2026 13:30:49 +0000 Subject: [PATCH 1/2] publish.sh: surface PR-open and git-push failures as issue comments --- .gitea/workflows/scripts/publish.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/scripts/publish.sh b/.gitea/workflows/scripts/publish.sh index 2422a4f..de880d5 100755 --- a/.gitea/workflows/scripts/publish.sh +++ b/.gitea/workflows/scripts/publish.sh @@ -334,7 +334,15 @@ if [ -n "$(git status --porcelain)" ]; then git add -A git commit -m "@$NAME: issue #$NUM" fi -git push origin "HEAD:$BRANCH" || true +push_ok=0 +if git push origin "HEAD:$BRANCH"; then + push_ok=1 +else + 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")" + exit 0 +fi git fetch -q origin 2>/dev/null || true prbody=$(printf '%s\n\n---\nResolves #%s' "$prdesc" "$NUM") @@ -367,7 +375,12 @@ if [ -z "$url" ]; then url=$(printf '%s' "$resp" | jq -r '.html_url // empty' 2>/dev/null) prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null) fi -[ -z "$url" ] && { echo "PR open/lookup failed for $br — posting reply on issue instead"; post "$(printf '%s%s' "$reply" "$activity")"; exit 0; } +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) + echo "PR open/lookup failed for $br — response: $resp" + post "$(printf '⚠️ Failed to open PR for branch `%s`.%s\n\nGitea message: %s' "$br" "$activity" "$err_msg")" + exit 0 +fi # Posts to the PR thread when we have a PR number, else to the origin issue ($NUM). prpost() { -- 2.54.0 From 0a06c813bcaec9c8ed198b2d987d2b6cda8df6c0 Mon Sep 17 00:00:00 2001 From: junior Date: Mon, 27 Jul 2026 13:32:47 +0000 Subject: [PATCH 2/2] =?UTF-8?q?publish.sh:=20address=20review=20=E2=80=94?= =?UTF-8?q?=20fix=20PR-failure=20format,=20capture=20HTTP=20status,=20appe?= =?UTF-8?q?nd=20activity=20to=20push=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/scripts/publish.sh | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.gitea/workflows/scripts/publish.sh b/.gitea/workflows/scripts/publish.sh index de880d5..708a567 100755 --- a/.gitea/workflows/scripts/publish.sh +++ b/.gitea/workflows/scripts/publish.sh @@ -334,13 +334,12 @@ if [ -n "$(git status --porcelain)" ]; then git add -A git commit -m "@$NAME: issue #$NUM" fi -push_ok=0 if git push origin "HEAD:$BRANCH"; then - push_ok=1 + : else 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 fi 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) if [ -z "$url" ]; then 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" \ '{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) prnum=$(printf '%s' "$resp" | jq -r '.number // empty' 2>/dev/null) fi 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) - echo "PR open/lookup failed for $br — response: $resp" - post "$(printf '⚠️ Failed to open PR for branch `%s`.%s\n\nGitea message: %s' "$br" "$activity" "$err_msg")" + echo "PR open/lookup failed for $br — HTTP $http_status — response: $resp" + 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 fi -- 2.54.0