Skip to content

Instantly share code, notes, and snippets.

@rms1000watt
Last active July 24, 2018 22:57
Show Gist options
  • Save rms1000watt/600690c6f11c262475eb66a7c82cbe72 to your computer and use it in GitHub Desktop.
Save rms1000watt/600690c6f11c262475eb66a7c82cbe72 to your computer and use it in GitHub Desktop.
Pull PRs From Github
#!/usr/bin/env bash
get-all() {
if [[ -z $GITHUB_ACCESS_TOKEN ]]; then
echo "ERROR: no GITHUB_ACCESS_TOKEN defined"
exit 1
fi
pages=(1 2 3 4 5 6 7 8)
for page in ${pages[*]}; do
curl -H "Authorization: token $GITHUB_ACCESS_TOKEN" "https://api.github.com/repos/rms1000watt/serverless-tf/pulls?state=closed&page=$page" > "prs-page-$page.json"
sleep 5
done
}
join-all() {
prFiles=""
for file in prs-page-*.json; do
prFiles+=" $file"
done
jq -s '.|flatten' $prFiles > prs-all.json
}
parse-all() {
jq '.[].title' < prs-all.json
}
case "$1" in
get-all)
get-all;;
join-all)
join-all;;
parse-all)
parse-all;;
*)
echo "bad command" && exit 1;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment