Fetch PR body inside checker
test / test (pull_request) Successful in 8s

Authored-By: Codex (GPT-5) <noreply@openai.com>
This commit is contained in:
2026-08-27 18:17:27 +00:00
parent f7daa3f025
commit 76c72b02e2
5 changed files with 72 additions and 21 deletions
+15 -3
View File
@@ -7,11 +7,12 @@ set -euo pipefail
BRANCH="${HEAD_BRANCH:-}"
TITLE="${PR_TITLE:-}"
AUTHOR="${PR_AUTHOR:-}"
BODY="${PR_BODY:-}"
BASE="${BASE_SHA:-}"
HEAD="${HEAD_SHA:-}"
SERVER_URL="${GITEA_SERVER_URL:-}"
TOKEN="${GITEA_TOKEN:-}"
REPOSITORY="${GITEA_REPOSITORY:-}"
PR_NUMBER="${GITEA_PR_NUMBER:-}"
# Break-glass: dfritz is exempt from all naming checks.
if [ "${AUTHOR}" = "dfritz" ]; then
@@ -26,8 +27,19 @@ BRANCH_BUG=""
# Gitea's renderer is the visibility contract. Validate its output instead of
# maintaining a second Markdown parser in this action.
RENDERED_BODY=""
if [ -z "${SERVER_URL}" ] || [ -z "${TOKEN}" ]; then
echo "FAIL[check-naming]: server-url and token are required to render the PR body"
BODY=""
if [ -z "${SERVER_URL}" ] || [ -z "${TOKEN}" ] ||
! printf '%s' "${REPOSITORY}" | grep -qE '^[[:alnum:]_.-]+/[[:alnum:]_.-]+$' ||
! printf '%s' "${PR_NUMBER}" | grep -qE '^[1-9][0-9]*$'; then
echo "FAIL[check-naming]: server-url, token, repository, and PR number are required to load the PR body"
FAILED=1
elif ! BODY=$(curl --fail --silent --show-error \
--connect-timeout 5 \
--max-time 15 \
--header "Authorization: token ${TOKEN}" \
"${SERVER_URL%/}/api/v1/repos/${REPOSITORY}/pulls/${PR_NUMBER}" |
jq -er '.body | if type == "string" then . else error("body is not a string") end'); then
echo "FAIL[check-naming]: Gitea could not load the PR body"
FAILED=1
elif ! RENDERED_BODY=$(printf '%s' "${BODY}" |
jq -Rs '{Text: ., Mode: "gfm"}' |