Skip to content

PR Review Guidance #16813

PR Review Guidance

PR Review Guidance #16813

Workflow file for this run

name: PR Review Guidance
on:
workflow_run:
workflows: ["CICD NeMo"]
types: [requested]
branches:
- "pull-request/[0-9]+"
issue_comment:
types: [created]
permissions: {}
jobs:
review-hint:
name: Review command hint
# Post guidance once for non-draft PRs when copy-pr-bot's
# pull-request/<number> push requests the CICD NeMo workflow.
# Skip bot-generated dependency bumps and auto cherry-picks.
if: |
github.event_name == 'workflow_run' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.actor.login == 'copy-pr-bot[bot]'
runs-on: ubuntu-latest
permissions:
pull-requests: write
concurrency:
group: ${{ github.workflow }}-review-hint-${{ github.event.workflow_run.head_branch }}
cancel-in-progress: false
steps:
- name: Post review command hint once
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8
with:
script: |
const branch = context.payload.workflow_run.head_branch;
const number = Number(branch.split("/").pop());
const { data: pr } = await github.rest.pulls.get({
...context.repo,
pull_number: number,
});
const shouldNotify =
pr.state === "open" &&
pr.head.sha === context.payload.workflow_run.head_sha &&
!pr.draft &&
!pr.head.ref.startsWith("bump-ci-container-") &&
!pr.head.ref.startsWith("cherry-pick-");
if (!shouldNotify) return;
const marker = "<!-- review-command-hint -->";
const comments = await github.paginate(github.rest.issues.listComments, {
...context.repo,
issue_number: number,
per_page: 100,
});
if (comments.some(comment =>
comment.user?.login === "github-actions[bot]" &&
comment.body?.includes(marker)
)) return;
await github.rest.issues.createComment({
...context.repo,
issue_number: number,
body: [
marker,
"Automatic Claude reviews have been retired. To request a pull-request review, post a comment containing:",
"",
"```",
"/review",
"```",
"",
"Add `model=claude` to use a Claude reviewer (the default is `model=codex`). " +
"`mode=light|strict` selects the review depth; for example, `/review model=claude mode=strict`. " +
"Comment `/review help` for all options.",
].join("\n"),
});
redirect-to-review:
name: Redirect to /review
if: |
github.event_name == 'issue_comment' &&
github.event.issue.pull_request &&
github.event.comment.user.type != 'Bot' &&
(contains(github.event.comment.body, '/claude review') ||
contains(github.event.comment.body, '/claude strict-review'))
runs-on: ubuntu-latest
permissions:
pull-requests: write
env:
GH_TOKEN: ${{ github.token }}
REPO: ${{ github.repository }}
PR_NUMBER: ${{ github.event.issue.number }}
RETIRED_COMMAND: ${{ contains(github.event.comment.body, '/claude strict-review') && '/claude strict-review' || '/claude review' }}
REVIEW_COMMAND: ${{ contains(github.event.comment.body, '/claude strict-review') && '/review mode=strict' || '/review' }}
steps:
- name: Explain the replacement command
env:
NOTICE: |
@${{ github.event.comment.user.login }} `${{ env.RETIRED_COMMAND }}` has been retired. Pull-request reviews now run through `/review`; comment this instead:
```
${{ env.REVIEW_COMMAND }}
```
Add `model=claude` to keep a Claude reviewer (the default is `model=codex`). `mode=light|strict` selects the review depth. Comment `/review help` for all options.
run: gh pr comment "$PR_NUMBER" --repo "$REPO" --body "$NOTICE"