Skip to content

Commit 3086639

Browse files
committed
ci: run manual reactions in the trigger job
Keep manual request reactions in the issue comment job so one job token owns their lifecycle.
1 parent d8b7790 commit 3086639

1 file changed

Lines changed: 50 additions & 4 deletions

File tree

.github/workflows/openai-pr-review-on-comment.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
head_sha: ${{ steps.pr.outputs.head_sha }}
3333
request_comment_id: ${{ steps.pr.outputs.request_comment_id }}
3434
review_focus: ${{ steps.pr.outputs.review_focus }}
35+
review: ${{ steps.codex.outputs.final-message }}
36+
env:
37+
PULL_REQUEST_NUMBER: ${{ steps.pr.outputs.number }}
38+
PR_BASE_SHA: ${{ steps.pr.outputs.base_sha }}
39+
PR_HEAD_SHA: ${{ steps.pr.outputs.head_sha }}
40+
REQUEST_COMMENT_ID: ${{ steps.pr.outputs.request_comment_id }}
3541
steps:
3642
- name: Authorize explicit review request
3743
id: pr
@@ -84,9 +90,49 @@ jobs:
8490
core.setOutput('base_sha', pullRequest.base.sha);
8591
core.setOutput('head_sha', pullRequest.head.sha);
8692
93+
- name: Check out trusted pull-request base commit
94+
if: steps.pr.outputs.eligible == 'true'
95+
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
96+
with:
97+
ref: ${{ steps.pr.outputs.base_sha }}
98+
persist-credentials: false
99+
100+
- name: Mark manual request in progress
101+
id: request_reaction
102+
if: steps.pr.outputs.eligible == 'true' && env.REQUEST_COMMENT_ID != ''
103+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
104+
with:
105+
script: |
106+
const { data: reaction } = await github.rest.reactions.createForIssueComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: Number(process.env.REQUEST_COMMENT_ID), content: 'eyes' });
107+
core.setOutput('reaction_id', String(reaction.id));
108+
109+
- name: Review pull request with OpenAI
110+
id: codex
111+
if: steps.pr.outputs.eligible == 'true'
112+
uses: openai/codex-action@52fe01ec70a42f454c9d2ebd47598f9fd6893d56 # v1
113+
with:
114+
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
115+
model: gpt-5.6-terra
116+
effort: medium
117+
sandbox: read-only
118+
safety-strategy: drop-sudo
119+
prompt: Review this pull request using its diff. Return a concise review.
120+
121+
- name: Record manual request result
122+
if: always() && steps.pr.outputs.request_comment_id != ''
123+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
124+
env:
125+
REQUEST_REACTION_ID: ${{ steps.request_reaction.outputs.reaction_id }}
126+
REVIEW_OUTCOME: ${{ steps.codex.outcome }}
127+
with:
128+
script: |
129+
const commentId = Number(process.env.REQUEST_COMMENT_ID); const reactionId = Number(process.env.REQUEST_REACTION_ID);
130+
if (reactionId) await github.request('DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id}', { owner: context.repo.owner, repo: context.repo.repo, comment_id: commentId, reaction_id: reactionId });
131+
await github.rest.reactions.createForIssueComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: commentId, content: process.env.REVIEW_OUTCOME === 'success' ? 'rocket' : process.env.REVIEW_OUTCOME === 'cancelled' ? 'confused' : '-1' });
132+
87133
review:
88134
needs: pull-request
89-
if: needs.pull-request.outputs.eligible == 'true'
135+
if: false
90136
runs-on: ubuntu-latest
91137
permissions:
92138
contents: read
@@ -207,14 +253,14 @@ jobs:
207253
});
208254
209255
publish:
210-
needs: [pull-request, review]
211-
if: needs.review.result == 'success'
256+
needs: [pull-request]
257+
if: false
212258
runs-on: ubuntu-latest
213259
permissions:
214260
contents: read
215261
pull-requests: write
216262
env:
217-
REVIEW: ${{ needs.review.outputs.review }}
263+
REVIEW: ${{ needs.pull-request.outputs.review }}
218264
PULL_REQUEST_NUMBER: ${{ needs.pull-request.outputs.number }}
219265
PR_HEAD_SHA: ${{ needs.pull-request.outputs.head_sha }}
220266
steps:

0 commit comments

Comments
 (0)