Skip to content

Instantly share code, notes, and snippets.

@henryhchchc
Created October 3, 2022 02:22
Show Gist options
  • Save henryhchchc/fcef677ffa127289e7e0de618d907100 to your computer and use it in GitHub Desktop.
Save henryhchchc/fcef677ffa127289e7e0de618d907100 to your computer and use it in GitHub Desktop.
Automation script for accept all the repository invitation on GitHub
#! /bin/sh
API_KEY="$1"
[ -z $API_KEY ] && echo "Usage: \n\taccept-invitation.sh <API_KEY>" && exit 1
INVITATION_IDS=$(curl -s -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $API_KEY" https://api.github.com/user/repository_invitations | jq -r ".[].id")
for id in $INVITATION_IDS; do
curl \
-s \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $API_KEY" \
"https://api.github.com/user/repository_invitations/$id"
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment