Skip to content

Instantly share code, notes, and snippets.

@ziadoz
Last active June 29, 2022 21:51
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 ziadoz/37b999970a3b579f7f61c6a9232c7736 to your computer and use it in GitHub Desktop.
Save ziadoz/37b999970a3b579f7f61c6a9232c7736 to your computer and use it in GitHub Desktop.
GitHub - Get All Your PRs As JSON
#!/usr/bin/env bash
# Install GH CLI client
brew install gh
# Configure organisation and username variables
ORG="orgname"
USER="username"
# Retrieve pull request JSON
# @see: https://github.com/cli/cli/issues/1268
gh api --method GET /search/issues --raw-field q='is:pr org:$ORG author:$USER' --paginate | jq 'reduce inputs as $i (.; . += $i)' > pull_requests.json
gh api --method GET /search/issues --raw-field q='type:pr author:$USER' --paginate | jq > pull_requests.json
gh api --method GET /search/issues --raw-field q='type:pr author:$USER' --jq '.items.[].title' --paginate > pull_requests.json
gh api --method GET /search/issues --raw-field q='type:pr author:$USER' --jq '.items.[] | {title,body}' --paginate > pull_requests.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment