Skip to content

Instantly share code, notes, and snippets.

@vagelim
Created May 23, 2024 18:19
Show Gist options
  • Save vagelim/08824ead6e6ba7636641b89544ef81c5 to your computer and use it in GitHub Desktop.
Save vagelim/08824ead6e6ba7636641b89544ef81c5 to your computer and use it in GitHub Desktop.
add team to all repos in a github org
export ORG=<organization-name>
export PERMISSION=<admin|push|pull>
export TEAM_SLUG=<team-name-in-url>
gh repo list ${ORG} --limit 1000 | awk '{print $1}' | while read -r OWNED_REPO
do
gh api --method PUT \
-H "Accept: application/vnd.github.v3.repository+json" -H "X-GitHub-Api-Version: 2022-11-28" \
/orgs/${ORG}/teams/${TEAM_SLUG}/repos/${OWNED_REPO} -f permission=${PERMISSION}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment