fixed action from exiting because a PR already existed.
This commit is contained in:
+8
-4
@@ -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")"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user