From b59e66eca8c46efeb05969084e53da0ac5272986 Mon Sep 17 00:00:00 2001 From: james Date: Sun, 27 Jul 2025 22:26:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/test.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/test.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitea/workflows/test.yml b/.gitea/workflows/test.yml index 01b76b4..51329d0 100644 --- a/.gitea/workflows/test.yml +++ b/.gitea/workflows/test.yml @@ -3,6 +3,9 @@ on: pull_request: branches: - main +env: + GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} + jobs: test: runs-on: phpunit_test @@ -11,6 +14,14 @@ jobs: - name: Checkout code uses: http://119.91.43.128:3003/james/checkout@v4 + - name: Get Pull Request Number + id: get_pr_number + run: | + # 提取 PR 编号(如 pull/14/head -> 14) + PULLS_ID=$(git branch | grep -o 'pull/[0-9]\+' | cut -d'/' -f2) + echo "PR ID: $PULLS_ID" + echo "PULLS_ID=$PULLS_ID" >> $GITHUB_ENV + - name: Run code review script env: GIT_PROJECT_PATH: /workspace/hui/SCTMES_V5 # Gitea 的工作目录 @@ -37,5 +48,20 @@ jobs: 如果没有发现相关问题,请一定输出以下JSON格式: {"status": "passed"} run: | + PR_NUMBER=$PULLS_ID + OWNER="hui" + REPO="SCTMES_V5" + SERVER_URL="http://119.91.43.128:3003" + + COMMENT="🧪 单元测试已完成。\n- 状态: 成YYYYY功 ✅\n- Commit ID: $(git rev-parse HEAD)\n- 查看日志: [Actions](https://your-ci-link-here)" + + API_URL="$SERVER_URL/api/v1/repos/$OWNER/$REPO/issues/$PR_NUMBER/comments" + + curl -X POST \ + -H "Authorization: token $GITEA_TOKEN" \ + -H "Content-Type: application/json" \ + -d "{\"body\": \"$COMMENT\"}" \ + "$API_URL" + cd /workspace ./audit_code.sh \ No newline at end of file