From d5623bdf9c26517f881adcab9f0c89c62944a1ea Mon Sep 17 00:00:00 2001 From: Joakim Olsson Date: Mon, 23 Feb 2026 14:12:43 +0100 Subject: [PATCH] fix(release): add retry and delay for PR creation to handle Gitea API race condition The PR creation curl immediately follows branch creation via the Contents API, but Gitea may not have fully indexed the new branch for pull request operations yet. This causes intermittent HTTP errors on the first run. - Add sleep 3 before PR creation to allow Gitea to process the new branch - Use --retry-all-errors so curl retries on HTTP 4xx/5xx (not just connection failures) - Capture and display the actual HTTP error code and response body on failure for easier debugging Co-Authored-By: Claude Opus 4.6 --- .gitea/workflows/Release.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitea/workflows/Release.yml b/.gitea/workflows/Release.yml index 16a88a2..72695cc 100644 --- a/.gitea/workflows/Release.yml +++ b/.gitea/workflows/Release.yml @@ -189,7 +189,11 @@ jobs: fi echo "Creating new PR..." - curl -sf --retry 3 --retry-delay 2 --retry-connrefused -X POST \ + echo "Waiting for branch to be ready..." + sleep 3 + + RESPONSE=$(curl -s --retry 3 --retry-delay 3 --retry-all-errors --retry-connrefused \ + -w "\n%{http_code}" -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ --data "$(jq -n \ @@ -198,7 +202,14 @@ jobs: --arg head "next-release" \ --arg base "${DEFAULT_BRANCH}" \ '{title: $title, body: $body, head: $head, base: $base}')" \ - "${API_URL}/pulls" + "${API_URL}/pulls") + HTTP_CODE=$(echo "${RESPONSE}" | tail -1) + BODY=$(echo "${RESPONSE}" | sed '$d') + if [ "${HTTP_CODE}" -ge 400 ]; then + echo "Error creating PR (HTTP ${HTTP_CODE}): ${BODY}" + exit 1 + fi + echo "PR created successfully" create-release: name: Create Release -- 2.52.0