Skip to content

Instantly share code, notes, and snippets.

@a11ce
Created January 3, 2022 17:21
Show Gist options
  • Save a11ce/72d8136069ca1f1667127bf239e9c358 to your computer and use it in GitHub Desktop.
Save a11ce/72d8136069ca1f1667127bf239e9c358 to your computer and use it in GitHub Desktop.
#!/bin/bash
# no set -e because gh might 404
set -uo pipefail
IFS=$'\n\t'
if test "$#" -ne 2; then
echo "run as ./github-add-collabs.sh user/repo usernames.txt"
exit
fi
while read username; do
echo "adding $username..."
gh api --silent -XPUT "repos/$1/collaborators/$username" -f permission=push
if test "$?" -ne 0; then
echo -e "\033[0;31m!!!! could not find $username\033[0m"
fi
done < $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment