From 4b011fe8b1cc4f3ad3f05f3cea3980678d56a389 Mon Sep 17 00:00:00 2001 From: shaw Date: Thu, 16 Oct 2025 14:32:27 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=20Codex=20PR=20?= =?UTF-8?q?=E5=AE=A1=E8=AE=A1=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/codex-pr-review.yml | 70 +++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/workflows/codex-pr-review.yml diff --git a/.github/workflows/codex-pr-review.yml b/.github/workflows/codex-pr-review.yml new file mode 100644 index 00000000..140f2b7f --- /dev/null +++ b/.github/workflows/codex-pr-review.yml @@ -0,0 +1,70 @@ +name: Codex PR Review + +on: + pull_request: + types: [opened] + +jobs: + codex: + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + final_message: ${{ steps.run_codex.outputs['final-message'] }} + environment: CODEX + name: Codex PR Review + steps: + - name: Checkout + uses: actions/checkout@v5 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Pre-fetch base and head refs for the PR + run: | + git fetch --no-tags origin \ + ${{ github.event.pull_request.base.ref }} \ + +refs/pull/${{ github.event.pull_request.number }}/head + + - name: Run Codex + id: run_codex + uses: hewenyu/codex-action@crs + with: + crs-api-key: ${{ secrets.CRS_API_KEY }} + crs-base-url: ${{ secrets.CRS_API_BASE_URL }} + crs-model: "gpt-5-codex" + crs-reasoning-effort: "high" + prompt: | + This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}. + Base SHA: ${{ github.event.pull_request.base.sha }} + Head SHA: ${{ github.event.pull_request.head.sha }} + + Review ONLY the changes introduced by the PR. + Suggest any improvements, potential bugs, or issues. + Be concise and specific in your feedback. + + Pull request title and body: + ---- + ${{ github.event.pull_request.title }} + ${{ github.event.pull_request.body }} + + post_feedback: + runs-on: ubuntu-latest + needs: codex + if: needs.codex.outputs.final_message != '' + permissions: + issues: write + pull-requests: write + steps: + - name: Report Codex feedback + uses: actions/github-script@v7 + env: + CODEX_FINAL_MESSAGE: ${{ needs.codex.outputs.final_message }} + with: + github-token: ${{ github.token }} + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body: process.env.CODEX_FINAL_MESSAGE, + });