Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/auto-codex-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Auto Codex Review on PR

on:
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
codex-review:
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false && github.actor != 'dependabot[bot]'
steps:
- name: Request Codex review
uses: actions/github-script@v8
with:
github-token: ${{ secrets.CODEX_PAT }}
script: |
const pullRequest = context.payload.pull_request;
const prNumber = pullRequest.number;
const event = context.payload.action;
const headSha = pullRequest.head.sha;
const requestBody = [
'@codex review plz',
'',
`Event: ${event}`,
`Commit: ${headSha}`
].join('\n');

// Detect the PAT owner's login so dedup works regardless of which account owns the token
const { data: tokenUser } = await github.rest.users.getAuthenticated();
const botLogin = tokenUser.login;

const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
per_page: 100
Comment on lines +32 to +36
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Paginate comment lookup before deduplicating requests

The deduplication check only inspects the first page of issue comments (per_page: 100) and never follows pagination, so on PRs with more than 100 comments it can miss existing @codex review plz comments for the same commit and post duplicate requests on every trigger. This creates repeated bot noise on long-running/high-traffic PRs; iterate through all pages (or query newest comments first with pagination) before deciding no matching request exists.

Useful? React with 👍 / 👎.

});
const alreadyRequestedForCommit = comments.data.some(
c =>
c.user.login === botLogin &&
c.body.includes('@codex review plz') &&
c.body.includes(`Commit: ${headSha}`)
);
if (alreadyRequestedForCommit) {
console.log(`Codex review already requested for commit ${headSha}, skipping`);
return;
}

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: requestBody
});
console.log(`Requested Codex review on PR #${prNumber} for commit ${headSha}`);
31 changes: 31 additions & 0 deletions .github/workflows/codex-review.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Codex Review

on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to review'
required: true
type: number

permissions:
contents: read
issues: write

jobs:
request-review:
runs-on: ubuntu-latest
steps:
- name: Comment on PR to trigger Codex review
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = ${{ inputs.pr_number }};
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: '@codex review plz'
});
console.log(`Requested Codex review on PR #${prNumber}`);
Loading