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
gh pr review 123 --approve
gh pr review 123 --request-changes --body "Needs tests"
gh pr review 123 --comment --body "Looks reasonable"Flags
| Flag | What it does |
|---|---|
| -a, --approve | Approve the pull request |
| -r, --request-changes | Request changes (requires --body) |
| -c, --comment | Comment 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.
- 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