Last active
June 7, 2023 15:05
-
-
Save dahoba/6f124c3af9c7014e003c7e32d3a589ac to your computer and use it in GitHub Desktop.
shellscript that list all members under an organization in github private repo then find their username.
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/env bash | |
set -e | |
GITHUB_PAT=<your-github_pat> | |
ORG_LOGIN=<your-org-login> | |
results=$(curl --request GET --url "https://api.github.com/orgs/$ORG_LOGIN/members?per_page=80&page=1" --header 'Accept: application/vnd.github+json' --header "Authorization: Bearer $GITHUB_PAT" --header 'X-GitHub-Api-Version: 2022-11-28' | jq '[.[].url]' ) | |
for result in $(echo "${results}" | jq -r '.[]') ; do | |
# echo "exe command: $result" | |
curl -s --request GET --url $(echo $result) --header 'Accept: application/vnd.github+json' --header "Authorization: Bearer $GITHUB_PAT" --header 'X-GitHub-Api-Version: 2022-11-28' | jq '"\(.name)"' | |
sleep 1; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment