You can have Codex review every new pull request by adding OpenAI's openai/codex-action to a GitHub Actions workflow: one job runs Codex with read-only access, and a second job posts its feedback as a comment. Codex never merges anything; a person on your team still approves.
This guide walks through that setup with the safety settings the action's own docs recommend.
Based on openai/codex-action, by OpenAI, Apache-2.0 license. We checked version v1.13 (released 2026-10-05, per the changelog) on 2026-10-28.
What the action does
The action installs the Codex CLI on the runner, starts a proxy to the Responses API so Codex can call the model, and runs codex exec with your prompt. Its only output is final-message, the last message Codex returns. What you do with that text is up to your workflow.
OpenAI also offers a hosted Codex code review in Codex cloud. The README presents the action as the option for teams that want "more control over the experience." That control is the point of this guide: you choose the prompt, the permissions, and who sees the output.
Before you start
- An OpenAI API key, saved as a repository secret named
OPENAI_API_KEY. Azure OpenAI also works through theresponses-api-endpointinput. - A Linux GitHub-hosted runner such as
ubuntu-latest. Windows runners lack a supported sandbox and must usesafety-strategy: unsafe, so skip them for this. - Branch protection on your main branch that requires an approving review before merge. GitHub's protected branches docs explain the "Require pull request reviews before merging" rule.
The workflow
Save this as .github/workflows/codex-review.yml. It follows the README's pull request bot example, with two changes for a review-only job: the :read-only permission profile instead of :workspace, and the action pinned to the v1.13 commit instead of the moving v1 tag.
name: Codex review
on:
pull_request:
types: [opened]
jobs:
codex:
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
persist-credentials: false
- name: Fetch base and head refs
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
id: run_codex
uses: openai/codex-action@bdf19a4a223ec2549a3e2274a0cf61556bc07675 # v1.13
with:
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
permission-profile: ":read-only"
prompt: |
Review ONLY the changes in this pull request:
git log --oneline ${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}
Point out bugs, risks, and missing tests. Be concise and specific.
post_feedback:
runs-on: ubuntu-latest
needs: codex
if: needs.codex.outputs.final_message != ''
permissions:
issues: write
pull-requests: write
steps:
- 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,
});We left the pull request title and body out of the prompt on purpose. The security guide warns that a PR body can hide instructions in an HTML comment that the model reads but a person does not see. Codex can still read the diff and commit messages, which are also untrusted, so treat its comment as input to a review, not a verdict.
Why each setting is there
Two jobs. The Codex job only has contents: read. The job that can write comments never runs Codex. The security guide recommends running the action as the last step in a job, because after Codex runs "there are no guarantees what the state of the host is," and passing the output to a fresh job is the pattern it shows.
permission-profile: ":read-only". Codex permission profiles set filesystem and network limits for the commands Codex runs. :read-only keeps them read-only; :workspace allows writes inside the workspace. A reviewer does not need to write. Profiles are marked beta in the Codex docs and need Codex CLI 0.138.0 or later, so don't combine them with an older codex-version pin.
safety-strategy left at drop-sudo. This default removes the runner user's sudo access before Codex starts. The security guide is blunt about why: read-only file access plus passwordless sudo, the default on GitHub-hosted runners, can be enough to expose your API key. Never switch to unsafe for a review workflow.
Write access gate. By default only users with write access to the repo can trigger the action. The allow-users input widens that list. The security guide notes that setting it to "*" invites people to spend your API quota on their own tasks.
Env vars, not inline expressions. The fetch step passes branch names through env: and quotes them, which the guide recommends to avoid shell injection.
Pinned commit. Pinning to a full commit SHA means a future release can't change your workflow until you update it on purpose. Read the changelog before you bump it.
The human approval step
Codex posts a comment and stops there. It cannot approve, push, or merge with this setup, because the Codex job has no write token and the posting job only creates a comment. The merge decision belongs to the person who reviews the PR, enforced by your branch protection rule. If you later give Codex the :workspace profile to suggest fixes, keep those changes in a branch that goes through the same review.
Next step
Add the workflow to a test repository, open a small pull request, and read the comment Codex leaves before you roll it out more widely. For running Codex locally first, see our Codex CLI kit. To compare with a Claude-based reviewer, see the Claude PR review kit, or find an agent for the job.
Good setups, worth keeping. Request email updates on the home page, then confirm by email. No subscription starts until you confirm.
