Created
October 12, 2015 16:04
-
-
Save danmactough/9289a0e8e371962216de to your computer and use it in GitHub Desktop.
I needed to add a read-only collaborator to many repositories, and doing it via the website was really tedious
This file contains 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_TOKEN=$(git config --global github.token) # I've defined an API token in my git config -- ymmv | |
GITHUB_USER="" # the collaborator | |
REPO_OWNER="" # the owner of the repos | |
REPOS="" # space-delimited list of repositories | |
PERMISSION="pull" # may be one of "admin", "push" (i.e., read/write -- default), or "pull" (i.e., read-only) | |
for REPO in ${REPOS} ; do | |
curl -X PUT -i -d '{ "permission": "'${PERMISSION}'" }' \ | |
-H 'Accept: application/vnd.github.ironman-preview+json' \ | |
-H "Authorization: token ${GITHUB_TOKEN}" \ | |
https://api.github.com/repos/${REPO_OWNER}/${REPO}/collaborators/${GITHUB_USER} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment