Created
September 10, 2018 03:07
-
-
Save clydet/9aaf8b1f3e3e5ccf27ff1b3e3272925e to your computer and use it in GitHub Desktop.
extract member info from github
This file contains 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 | |
TOKEN=${1} | |
HOST=${2} | |
ORG=${3} | |
PAGE_COUNT=100 | |
OUT_FILE='./temp.csv' | |
ORG_URL="https://${HOST}/api/v3/orgs/${ORG}" | |
query_git () { | |
echo $(curl -s -H "Authorization: token ${TOKEN}" "${ORG_URL}${1}") | |
} | |
MEMBER_COUNT=$(query_git | jq '.plan.filled_seats') | |
echo "Login" > ${OUT_FILE} | |
for((i=0;$MEMBER_COUNT>($PAGE_COUNT*$i);i++)) do | |
query_git "/members?page=$(($i+1))&per_page=${PAGE_COUNT}" \ | |
| jq -r '.[] | .login' >> ${OUT_FILE} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment