From c6ff15f17b280873262a2673114d96da0f444612 Mon Sep 17 00:00:00 2001 From: noahpombas Date: Tue, 13 Oct 2026 07:54:01 +0200 Subject: [PATCH] fixed action from exiting because a PR already existed. --- action.yaml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 1a9cc43..0d37f53 100644 --- a/action.yaml +++ b/action.yaml @@ -13,7 +13,6 @@ inputs: token: description: "Gitea token with pull-request write access" required: true - default: ${{ secrets.GITHUB_TOKEN }} title: description: "Pull request title" required: true @@ -67,9 +66,6 @@ runs: echo "::notice::Creating pull request ${REPOSITORY}: ${HEAD} -> ${BASE}" - echo "${GITEA_URL}" - echo "${REPOSITORY}" - STATUS="$( curl -sS -o "$RESPONSE" -w "%{http_code}" \ -X POST \ @@ -82,6 +78,13 @@ runs: if [ "$STATUS" != 201 ]; then cat "$RESPONSE" echo "----" + + # Gitea returns 409 when a PR for this head/base is already open. + if jq -e '.message | test("already exists")' "$RESPONSE" >/dev/null; then + echo "::notice::Pull request already exists. Nothing to do." + exit 0 + fi + echo "::error::create failed with HTTP ${STATUS}" exit 1 fi @@ -91,3 +94,4 @@ runs: echo "url=$(jq -r '.url' "$RESPONSE")" >> "$GITHUB_OUTPUT" echo "html_url=$(jq -r '.html_url' "$RESPONSE")" >> "$GITHUB_OUTPUT" echo "::notice::Pull request #${NUMBER}: $(jq -r '.html_url' "$RESPONSE")" +