Background
The shared OpenAI PR review workflow accepts @codex commands from pull-request comments through the issue_comment event. GitHub associates that event's workflow run with the repository default branch, so the actual Codex review run is shown against main even though the comment belongs to a specific pull request and the workflow resolves that pull request's head SHA.
For example, a command on h2vivi/firmwares#393 reviewed the correct pull-request diff, but the OpenAI PR Review Actions run was attached to main rather than the pull request's current head ref/SHA.
Reaction feedback is already the intended interface: 👀 while processing, 🚀 on success, and 👎 on failure. This bug does not request GitHub Check Runs or a different feedback mechanism.
Goal
Ensure that the actual comment-triggered Codex review run executes on and is associated with the ref/SHA of the pull request containing the @codex comment, rather than the caller repository's default branch.
A minimal listener/dispatcher run may remain on the default branch because issue_comment is a repository-level event. The model review job must run in a separately dispatched workflow run targeting the resolved internal pull request's current head ref. Existing reaction behavior and native review publication remain unchanged.
Code Changes Tree
.github/workflows/
├── openai-pr-review-dispatch.yml # resolve comment PR and dispatch review to its head ref
└── codex-openai-review.yml # run the dispatched review for the resolved PR inputs
README.md # document caller event/dispatch wiring and run association
Design
Comment listener and dispatch
- Keep
issue_comment: created as the single command trigger for @codex comments.
- The listener validates the existing command grammar and collaborator permission, resolves the open non-draft internal pull request, and reads its current
head.ref and head.sha.
- Instead of executing the Codex review in the
issue_comment run, dispatch a review workflow with ref set to the resolved pull-request head ref and explicit inputs for pull-request number, expected head SHA, and triggering comment ID.
- The dispatched workflow verifies that the pull request is still open, internal, non-draft, and still points to the expected head SHA before reviewing. A stale dispatch must stop without reviewing a newer or different revision.
- Concurrency remains keyed by repository and pull-request number so a newer
@codex request cancels or supersedes the older review.
Run association
- The listener may appear under
main; it performs only command validation and dispatch.
- The workflow run containing the Codex model review must be created with the pull-request head ref and must report that head SHA in Actions metadata.
- The review still uses the resolved pull-request diff and publishes the native review against the exact expected head commit.
Feedback and errors
- Preserve the current reaction-only progress/result contract: 👀 during processing, 🚀 after successful review publication, and 👎 on any dispatch, validation, model, or publication failure.
- Do not add or require GitHub Check Runs,
checks: write, PR status checks, or additional failure comments.
- If dispatch cannot target the head ref, the listener records failure through the existing reaction behavior and must not silently fall back to running the model review on
main.
Caller contract
- Document the required caller workflow events,
workflow_dispatch inputs, permissions, secret forwarding, and same-repository PR limitation.
- Keep the shared entrypoint versionable so consuming repositories can pin a release tag.
Test And Acceptance Criteria
Background
The shared OpenAI PR review workflow accepts
@codexcommands from pull-request comments through theissue_commentevent. GitHub associates that event's workflow run with the repository default branch, so the actual Codex review run is shown againstmaineven though the comment belongs to a specific pull request and the workflow resolves that pull request's head SHA.For example, a command on
h2vivi/firmwares#393reviewed the correct pull-request diff, but the OpenAI PR Review Actions run was attached tomainrather than the pull request's current head ref/SHA.Reaction feedback is already the intended interface: 👀 while processing, 🚀 on success, and 👎 on failure. This bug does not request GitHub Check Runs or a different feedback mechanism.
Goal
Ensure that the actual comment-triggered Codex review run executes on and is associated with the ref/SHA of the pull request containing the
@codexcomment, rather than the caller repository's default branch.A minimal listener/dispatcher run may remain on the default branch because
issue_commentis a repository-level event. The model review job must run in a separately dispatched workflow run targeting the resolved internal pull request's current head ref. Existing reaction behavior and native review publication remain unchanged.Code Changes Tree
Design
Comment listener and dispatch
issue_comment: createdas the single command trigger for@codexcomments.head.refandhead.sha.issue_commentrun, dispatch a review workflow withrefset to the resolved pull-request head ref and explicit inputs for pull-request number, expected head SHA, and triggering comment ID.@codexrequest cancels or supersedes the older review.Run association
main; it performs only command validation and dispatch.Feedback and errors
checks: write, PR status checks, or additional failure comments.main.Caller contract
workflow_dispatchinputs, permissions, secret forwarding, and same-repository PR limitation.Test And Acceptance Criteria
@codexor@codex reviewon an eligible internal pull request creates a listener run on the default branch and a separate model-review run associated with that pull request's current head ref/SHA.mainrun and does not execute in the originalissue_commentrun.checks: writerequirement.main.actionlintpasses for all changed workflows.