Last active
August 4, 2024 06:35
-
-
Save eggplants/4536ffd4c59e2ba166068090e8818f03 to your computer and use it in GitHub Desktop.
Get gpg key hash of GitHub followers / followees
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
#!/usr/bin/env bash | |
set -eu | |
requirements=(curl gh gpg grep sed tee) | |
if ! command -v "${requirements[@]}" &>/dev/null | |
then | |
echo "required: ${requirements[*]}" >&2 | |
exit 1 | |
fi | |
if ! gh auth status &>/dev/null | |
then | |
echo 'first: `gh auth login`' >&2 | |
exit 1 | |
fi | |
get_followees() { | |
# <jq query> <page index number> | |
gh api --cache 1h -q "$1" "/user/following?per_page=100&page=$2" | |
} | |
for ((page=1;;page++)) | |
do | |
get_followees '.[].login' "$page" | |
[[ "$(get_followees 'length' $page)" = '100' ]] || break | |
done > followees | |
while read -r id | |
do | |
curl -s 'https://github.com/'"$id"'.gpg' | | |
gpg --show-keys --fingerprint | | |
grep pub -A1 | | |
sed "/[-\[]/d;s/ //g;s/^/${id}\t/" | |
done < followees | tee followees_hash.tsv |
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
#!/usr/bin/env bash | |
set -eu | |
requirements=(curl gh gpg grep sed tee) | |
if ! command -v "${requirements[@]}" &>/dev/null | |
then | |
echo "required: ${requirements[*]}" >&2 | |
exit 1 | |
fi | |
if ! gh auth status &>/dev/null | |
then | |
echo 'first: `gh auth login`' >&2 | |
exit 1 | |
fi | |
get_followers() { | |
# <jq query> <page index number> | |
gh api --cache 1h -q "$1" "/user/followers?per_page=100&page=$2" | |
} | |
for ((page=1;;page++)) | |
do | |
get_followers '.[].login' "$page" | |
[[ "$(get_followers 'length' $page)" = '100' ]] || break | |
done > followers | |
while read -r id | |
do | |
curl -s 'https://github.com/'"$id"'.gpg' | | |
gpg --show-keys --fingerprint | | |
grep pub -A1 | | |
sed "/[-\[]/d;s/ //g;s/^/${id}\t/" | |
done < followers | tee followers_hash.tsv |
Author
eggplants
commented
Aug 4, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment