Created
October 7, 2024 20:58
-
-
Save marcusmueller/8b2f1d7cc5999446077cf1b706c0698a to your computer and use it in GitHub Desktop.
Accept all invitations from specified github user
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 | |
# needs gh (off. github CLI) + jq | |
# | |
inviter="$1" | |
tmpdir="$(mktemp -d)" | |
gh api \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/user/repository_invitations \ | |
> "${tmpdir}/all.json" | |
inviteids="$(< "${tmpdir}/all.json" jq '.[] | select(.inviter.login == "'"${inviter}"'") | .id')" | |
for iid in ${inviteids}; | |
do | |
gh api \ | |
--method PATCH \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/user/repository_invitations/${iid} \ | |
| cat | |
done | |
rm -r "${tmpdir}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment