Skip to content

Instantly share code, notes, and snippets.

@bukzor
Created January 25, 2024 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bukzor/32840ac573137b48a4ceb47325e431ac to your computer and use it in GitHub Desktop.
Save bukzor/32840ac573137b48a4ceb47325e431ac to your computer and use it in GitHub Desktop.
using gh cli to find appoval state of PR
$ # stealing the command used for is_closed
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json state
{
"state": "OPEN"
}
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json
Specify one or more comma-separated fields for `--json`:
additions
assignees
author
autoMergeRequest
baseRefName
body
changedFiles
closed
closedAt
comments
commits
createdAt
deletions
files
headRefName
headRefOid
headRepository
headRepositoryOwner
id
isCrossRepository
isDraft
labels
latestReviews
maintainerCanModify
mergeCommit
mergeStateStatus
mergeable
mergedAt
mergedBy
milestone
number
potentialMergeCommit
projectCards
projectItems
reactionGroups
reviewDecision
reviewRequests
reviews
state
statusCheckRollup
title
updatedAt
url
exit code: 1
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json reviews
{
"reviews": [
{
"id": "PRR_kwDOKu3GpM5t4bxo",
"author": {
"login": "ellisonmarks"
},
"authorAssociation": "MEMBER",
"body": "LGTM",
"submittedAt": "2024-01-25T11:42:10Z",
"includesCreatedEdit": false,
"reactionGroups": [],
"state": "APPROVED",
"commit": {
"oid": "d67e2fa5eb83cb26207c6af3643175d5d212f1a4"
}
}
]
}
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json reviews --jq '.reviews[] | .state'
APPROVED
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json reviews --jq '.reviews | map(select(.state == "APPROVED"))'
[
{
"author": {
"login": "ellisonmarks"
},
"authorAssociation": "MEMBER",
"body": "LGTM",
"commit": {
"oid": "d67e2fa5eb83cb26207c6af3643175d5d212f1a4"
},
"id": "PRR_kwDOKu3GpM5t4bxo",
"includesCreatedEdit": false,
"reactionGroups": [],
"state": "APPROVED",
"submittedAt": "2024-01-25T11:42:10Z"
}
]
$ gh pr view https://github.com/getsentry/tacos-gha/pull/77 --json reviews --jq '.reviews | map(select(.state == "APPROVED")) | length > 0'
true
$ gh pr view https://github.com/getsentry/tacos-gha/pull/85 --json reviews --jq '.reviews | map(select(.state == "APPROVED")) | length > 0'
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment