diff --git a/.github/workflows/codex-review.yml b/.github/workflows/codex-review.yml new file mode 100644 index 0000000..525c810 --- /dev/null +++ b/.github/workflows/codex-review.yml @@ -0,0 +1,72 @@ +name: Codex Review + +on: + pull_request_target: + types: [opened, reopened, synchronize, ready_for_review] + +jobs: + codex-review: + if: github.event.pull_request.draft == false + runs-on: ubuntu-latest + permissions: + contents: read + outputs: + final_message: ${{ steps.run_codex.outputs.final-message }} + + steps: + - name: Check out PR merge commit + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + with: + ref: refs/pull/${{ github.event.pull_request.number }}/merge + + - name: Fetch base and head refs + run: | + git fetch --no-tags origin \ + ${{ github.event.pull_request.base.ref }} \ + +refs/pull/${{ github.event.pull_request.number }}/head + + - name: Run Codex review + id: run_codex + uses: openai/codex-action@v1 + with: + openai-api-key: ${{ secrets.OPENAI_API_KEY }} + prompt: | + You are reviewing PR #${{ github.event.pull_request.number }} for ${{ github.repository }}. + + Only review changes introduced by this PR: + git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} + + Focus on: + - correctness bugs and regressions + - security concerns + - missing tests or edge cases + + Keep feedback concise and actionable. + + Pull request title and body: + ---- + ${{ github.event.pull_request.title }} + ${{ github.event.pull_request.body }} + + post-feedback: + runs-on: ubuntu-latest + needs: codex-review + if: needs.codex-review.outputs.final_message != '' + permissions: + issues: write + pull-requests: write + + steps: + - name: Post Codex review as PR comment + uses: actions/github-script@v7 + env: + CODEX_FINAL_MESSAGE: ${{ needs.codex-review.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, + }); diff --git a/CHANGELOG.md b/CHANGELOG.md index 9daa2ed..e0ed6fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## Unreleased + +### Internal + +- Add a GitHub Actions workflow to run Codex review on pull requests. + ## 1.19.0 - 2026-01-30 ### Features