-
-
Save garlandkr/11f0fdfcfcc379368b649c6fd650c2ae to your computer and use it in GitHub Desktop.
Add repos to team with gh
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 | |
PERMISSION="push" # Can be one of: pull, push, admin, maintain, triage | |
ORG="orgname" | |
TEAM_SLUG="your-team-slug" | |
# Get names with `gh repo list orgname` | |
REPOS=( | |
"orgname/reponame" | |
) | |
for REPO in "${REPOS[@]}"; do | |
echo "Adding repo ${REPO} to Org:$ORG Team:$TEAM_SLUG" | |
# https://docs.github.com/en/rest/teams/teams#add-or-update-team-repository-permissions | |
# (needs admin:org scope) | |
# --silent added to make it less noisy | |
gh api \ | |
--method PUT \ | |
-H "Accept: application/vnd.github+json" \ | |
--silent \ | |
"/orgs/$ORG/teams/$TEAM_SLUG/repos/$REPO" \ | |
-f permission="$PERMISSION" && echo 'Added' || echo 'Failed' | |
echo "\n============================================================\n" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment