feat(ci): add codex PR review workflow
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
name: Codex PR Review
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
- ready_for_review
|
||||
|
||||
jobs:
|
||||
codex:
|
||||
if: github.event.pull_request.draft == false
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
outputs:
|
||||
final_message: ${{ steps.run_codex.outputs.final-message }}
|
||||
steps:
|
||||
- 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 review
|
||||
id: run_codex
|
||||
uses: openai/codex-action@v1
|
||||
with:
|
||||
openai-api-key: ${{ secrets.CODEX_API_KEY }}
|
||||
responses-api-endpoint: ${{ secrets.CODEX_RESPONSES_API_ENDPOINT }}
|
||||
prompt: |
|
||||
This is PR #${{ github.event.pull_request.number }} for ${{ github.repository }}.
|
||||
|
||||
Review only changes from this PR using:
|
||||
git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}
|
||||
|
||||
Focus on:
|
||||
- bugs and regressions
|
||||
- security issues
|
||||
- risky edge cases
|
||||
- missing tests where critical
|
||||
|
||||
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
|
||||
if: needs.codex.outputs.final_message != ''
|
||||
permissions:
|
||||
issues: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Post Codex feedback to PR
|
||||
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,
|
||||
});
|
||||
Reference in New Issue
Block a user