Skip to content
LatchkeyLatchkey home

gh pr review: Approve or Request Changes

gh pr review submits an approval, a request for changes, or a review comment on a pull request.

Bots that auto-approve dependency bumps or block on policy failures use gh pr review to submit a verdict programmatically.

What it does

gh pr review submits a pull request review with one of three verdicts: approve, request changes, or a plain comment. The verdict and an optional body become a formal review entry on the PR.

Common usage

Terminal
gh pr review 123 --approve
gh pr review 123 --request-changes --body "Needs tests"
gh pr review 123 --comment --body "Looks reasonable"

Flags

FlagWhat it does
-a, --approveApprove the pull request
-r, --request-changesRequest changes (requires --body)
-c, --commentComment without an explicit verdict (requires --body)
-b, --body <text>Review body text
-F, --body-file <file>Read the body from a file (- for stdin)
-R, --repo <owner/repo>Target a specific repository

In CI

Set GH_TOKEN and permissions: { pull-requests: write }. GitHub forbids approving your own PR, so a bot review only counts toward protection when the PR author is a different identity. --request-changes and --comment both require a non-empty --body.

Common errors in CI

"GraphQL: Can not approve your own pull request" appears when the token identity authored the PR. "GraphQL: Resource not accessible by integration" means the token lacks pull-requests: write or it is a fork run. "pull request review thread must contain a body" means --request-changes or --comment was used without --body.

Using this in CI

CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.

.github/workflows/ci.yml
- uses: actions/checkout@v4
  with:
    fetch-depth: 0   # history, tags, and git describe all need this

- run: |
    git rev-parse --is-shallow-repository   # expect false
    git rev-parse --abbrev-ref HEAD          # prints HEAD when detached

Frequently asked questions

gh pr review: Approve or Request Changes?
Bots that auto-approve dependency bumps or block on policy failures use gh pr review to submit a verdict programmatically.
What it does?
gh pr review submits a pull request review with one of three verdicts: approve, request changes, or a plain comment. The verdict and an optional body become a formal review entry on the PR.
In CI?
Set GH_TOKEN and permissions: { pull-requests: write }. GitHub forbids approving your own PR, so a bot review only counts toward protection when the PR author is a different identity. --request-changes and --comment both require a non-empty --body.
Common errors in CI?
"GraphQL: Can not approve your own pull request" appears when the token identity authored the PR. "GraphQL: Resource not accessible by integration" means the token lacks pull-requests: write or it is a fork run. "pull request review thread must contain a body" means --request-changes or --comment was used without --body.

Related guides

References

Run this faster and cheaper on Latchkey managed runners - self-healing included. Start free → 30-day trial · No credit card