Last active
January 5, 2025 02:16
-
-
Save danielwrobert/e7752e188037e2b3723abc7f5512e7ae to your computer and use it in GitHub Desktop.
GitHub CLI data-fetching queries. These can be used to upload as context into an AI tool (Claude, ChatGPT, etc.) for summary details, questions, etc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
YELLOW=$'\e[1;33m' | |
GREEN=$'\e[1;32m' | |
NOCOLOR=$'\e[0m' | |
read -r -p "Please enter the type of content you wish to export - pullRequest|issue|discussion (default = pullRequest): " type | |
type=${type:-pullRequest} | |
read -r -p "Please enter the repository owner: " owner | |
owner=${owner:-${owner}} | |
read -r -p "Please enter the repository name: " repo | |
repo=${repo:-${repo}} | |
read -r -p "Please enter the ${type} number: " number | |
number=${number:-${number}} | |
echo "${YELLOW}Fetching your data. Please hold...${NOCOLOR}" | |
gh api graphql -f query=" | |
query(\$owner:String!, \$repo:String!, \$number:Int!) { | |
repository(owner:\$owner, name:\$repo) { | |
${type}(number:\$number) { | |
title | |
body | |
comments(first:100) { | |
nodes { | |
author { | |
login | |
} | |
body | |
createdAt | |
} | |
} | |
} | |
} | |
} | |
" -F owner="${owner}" -F repo="${repo}" -F number="${number}" > "${type}-${number}.json" | |
echo "${GREEN}Export complete... you can find your JSON file at ./${type}-${number}.json!${NOCOLOR}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment