|
| 1 | +name: Codex Review |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: [opened, labeled, reopened, ready_for_review] |
| 6 | + paths-ignore: |
| 7 | + - '**.md' |
| 8 | + - '**.rst' |
| 9 | + - 'LICENSE.txt' |
| 10 | + - 'doc/**/*.txt' |
| 11 | + - '**/AUTHORS' |
| 12 | + - '**/SPONSORS' |
| 13 | + - '**/TIPS' |
| 14 | + - 'pgcli-completion.bash' |
| 15 | + - 'sanity_checks.txt' |
| 16 | + - 'post-install' |
| 17 | + - 'post-remove' |
| 18 | + - 'screenshots/**' |
| 19 | + |
| 20 | +jobs: |
| 21 | + codex-review: |
| 22 | + if: github.event.pull_request.draft == false || (github.event.action == 'labeled' && contains(github.event.pull_request.labels.*.name, 'codex')) |
| 23 | + runs-on: ubuntu-latest |
| 24 | + permissions: |
| 25 | + contents: read |
| 26 | + outputs: |
| 27 | + final_message: ${{ steps.run_codex.outputs.final-message }} |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Check out PR merge commit |
| 31 | + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 32 | + with: |
| 33 | + ref: refs/pull/${{ github.event.pull_request.number }}/merge |
| 34 | + |
| 35 | + - name: Fetch base and head refs |
| 36 | + run: | |
| 37 | + git fetch --no-tags origin \ |
| 38 | + ${{ github.event.pull_request.base.ref }} \ |
| 39 | + +refs/pull/${{ github.event.pull_request.number }}/head |
| 40 | +
|
| 41 | + - name: Run Codex review |
| 42 | + id: run_codex |
| 43 | + uses: openai/codex-action@v1 |
| 44 | + env: |
| 45 | + # Use env variables to handle untrusted metadata safely |
| 46 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 47 | + PR_BODY: ${{ github.event.pull_request.body }} |
| 48 | + with: |
| 49 | + openai-api-key: ${{ secrets.OPENAI_API_KEY }} |
| 50 | + prompt: | |
| 51 | + You are reviewing PR #${{ github.event.pull_request.number }} for ${{ github.repository }}. |
| 52 | +
|
| 53 | + Only review changes introduced by this PR: |
| 54 | + git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }} |
| 55 | +
|
| 56 | + Focus on: |
| 57 | + - correctness bugs and regressions |
| 58 | + - security concerns |
| 59 | + - missing tests or edge cases |
| 60 | +
|
| 61 | + Keep feedback concise and actionable. |
| 62 | +
|
| 63 | + Pull request title and body: |
| 64 | + ---- |
| 65 | + $PR_TITLE |
| 66 | + $PR_BODY |
| 67 | +
|
| 68 | + post-feedback: |
| 69 | + runs-on: ubuntu-latest |
| 70 | + needs: codex-review |
| 71 | + if: needs.codex-review.outputs.final_message != '' |
| 72 | + permissions: |
| 73 | + issues: write |
| 74 | + pull-requests: write |
| 75 | + |
| 76 | + steps: |
| 77 | + - name: Post Codex review as PR comment |
| 78 | + uses: actions/github-script@v8 |
| 79 | + env: |
| 80 | + CODEX_FINAL_MESSAGE: | |
| 81 | + ${{ format('## Codex Review |
| 82 | + {0}', needs.codex-review.outputs.final_message) }} |
| 83 | + with: |
| 84 | + github-token: ${{ github.token }} |
| 85 | + script: | |
| 86 | + await github.rest.issues.createComment({ |
| 87 | + owner: context.repo.owner, |
| 88 | + repo: context.repo.repo, |
| 89 | + issue_number: context.payload.pull_request.number, |
| 90 | + body: process.env.CODEX_FINAL_MESSAGE, |
| 91 | + }); |
0 commit comments