#!/usr/bin/env bash # Fetches the previous AI review comment from the PR (if any). # Required env vars: GITEA_TOKEN, GITEA_SERVER_URL, REPO, PR_NUMBER # Writes to $GITHUB_OUTPUT: prev_sha, prev_review set -euo pipefail COMMENTS=$(curl -sf \ -H "Authorization: token ${GITEA_TOKEN}" \ -H "Content-Type: application/json" \ "${GITEA_SERVER_URL}/api/v1/repos/${REPO}/issues/${PR_NUMBER}/comments") # Find the most recent comment that contains our SHA marker PREV_COMMENT=$(echo "$COMMENTS" | jq -r ' [ .[] | select(.body | contains(")' || true) # Strip the trailing marker line to get just the review body PREV_REVIEW=$(echo "$PREV_COMMENT" | sed '/