From d4a81d36dea1b93b1a1e963149ccda70961f1310 Mon Sep 17 00:00:00 2001 From: sgx <1186819569@qq.com> Date: Wed, 3 Sep 2025 09:25:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0AI=E5=AE=A1=E6=9F=A5=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E6=97=B6=E7=9A=84PR=E8=AF=84=E8=AE=BA=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/code-review.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/code-review.yml b/.gitea/workflows/code-review.yml index 427133d..5f3e55a 100644 --- a/.gitea/workflows/code-review.yml +++ b/.gitea/workflows/code-review.yml @@ -26,4 +26,26 @@ jobs: REVIEW_COMMENT_PREFIX: 'openai:' MAX_CODE_LENGTH: 6000 OPENAI_TOKEN: ${{ secrets.OPENAI_TOKEN }} - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + + - name: Comment on PR when AI review fails (Gitea API) + if: failure() # 仅在 AI Review 步骤失败时执行 + env: + GITEA_BASE_URL: https://49.235.186.195 + TOKEN: ${{ secrets.GH_TOKEN }} # 或者使用你在 Gitea 配置的 PAT + OWNER: ${{ github.repository_owner }} + REPO: ${{ github.event.repository.name }} + ISSUE_NUMBER: ${{ github.event.issue.number }} # PR 在 API 上也是 issue + run: | + set -e + api="$GITEA_BASE_URL/api/v1/repos/$OWNER/$REPO/issues/$ISSUE_NUMBER/comments" + body=$(cat <<'EOF' + { + "body": "AI 自动审查未通过,请根据机器人评论修复问题后,在此评论 `openai` 以重新触发审查。" + } + EOF + ) + curl -sS -X POST "$api" \ + -H "Content-Type: application/json" \ + -H "Authorization: token $TOKEN" \ + --data "$body" \ No newline at end of file