Last active
June 19, 2025 15:41
-
-
Save brianteeman/8fe5b14147471c0b10edaf649102d0c8 to your computer and use it in GitHub Desktop.
Github code contributors
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 | |
# github_realname.sh (no jq version) | |
GITHUB_TOKEN="insert_your_github_token_here" | |
REPO="insert_your_repo_here" | |
PAGES=10 # Increase if you expect more than 1000 contributors | |
echo '"login","name","avatar_url","html_url","contributions"' > all-contributors.csv | |
for page in $(seq 1 $PAGES); do | |
curl -s -H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/$REPO/contributors?per_page=100&page=$page" >> contributors_raw.json | |
done | |
# Extract contributor logins | |
grep -o '"login": *"[^"]*"' contributors_raw.json | sed 's/"login": *"\([^"]*\)"/\1/' | sort -u > logins.txt | |
while read -r login; do | |
# Fetch user details | |
user_json=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/users/$login") | |
# Extract fields using grep/sed | |
name=$(echo "$user_json" | grep -o '"name": *"[^"]*"' | sed 's/"name": *"\([^"]*\)"/\1/') | |
avatar_url=$(echo "$user_json" | grep -o '"avatar_url": *"[^"]*"' | head -1 | sed 's/"avatar_url": *"\([^"]*\)"/\1/') | |
html_url=$(echo "$user_json" | grep -o '"html_url": *"[^"]*"' | head -1 | sed 's/"html_url": *"\([^"]*\)"/\1/') | |
# Get contributions from contributors_raw.json | |
contributions=$(grep -A10 "\"login\": \"$login\"" contributors_raw.json | grep '"contributions":' | head -1 | sed 's/[^0-9]*\([0-9]*\).*/\1/') | |
# Output CSV row | |
printf '"%s","%s","%s","%s","%s"\n' "$login" "$name" "$avatar_url" "$html_url" "$contributions" >> all-contributors.csv | |
done < logins.txt | |
rm contributors_raw.json logins.txt | |
echo "Done! Output written to all-contributors.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment