-
Notifications
You must be signed in to change notification settings - Fork 0
77 lines (68 loc) · 2.45 KB
/
Copy pathcodex-review.yml
File metadata and controls
77 lines (68 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: Codex Review
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: codex-review-${{ github.repository }}-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
codex:
if: >-
github.event.pull_request.draft == false &&
github.event.pull_request.head.repo.full_name == github.repository &&
secrets.OPENAI_API_KEY != ''
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
env:
PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
git fetch --no-tags origin "$PR_BASE_REF" "+refs/pull/$PR_NUMBER/head"
- name: Run Codex review
id: run_codex
uses: openai/codex-action@v1
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
sandbox: read-only
prompt: |
You are a senior engineer doing a code review.
Review ONLY the changes introduced by this pull request.
Focus on correctness, security, reliability, performance, and maintainability.
Output format:
1) Summary (2-4 bullets)
2) Top risks (ordered)
3) Suggested fixes (actionable, reference files/paths)
4) Tests / edge cases to add
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:
pull-requests: write
issues: write
steps:
- name: Post Codex feedback as a PR comment
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,
});