Created
May 23, 2023 15:07
-
-
Save AndreyDodonov-EH/f30e26516ed83cfbd26f24329d40749c to your computer and use it in GitHub Desktop.
Give permission to all repos in a GitHub organisation for a certain team
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
| #name of your ogranisation | |
| #ORG=some_org | |
| #name of your team | |
| #TEAM_SLUG=some_team | |
| #permission to be given. Possible values are pull, triage, push, maintain, admin | |
| #PERMISSION=pull | |
| #more details on listing repos: https://docs.github.com/en/rest/repos/repos?apiVersion=2022-11-28#list-organization-repositories | |
| #more details on giving permission to a team https://docs.github.com/en/rest/teams/teams?apiVersion=2022-11-28#add-or-update-team-repository-permissions | |
| 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