Last active
June 11, 2021 14:33
-
-
Save maurofaccenda/06edc4cd1d0c3668c38c870f949df0c5 to your computer and use it in GitHub Desktop.
Script to give access to a Team to all repositories on a Organization
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
#!/usr/bin/env python3 | |
import os | |
import argparse | |
from github import Github | |
parser = argparse.ArgumentParser(description='Give access to a Team on all repositories from a Organization') | |
parser.add_argument('--team', help='Team name', required=True) | |
parser.add_argument('--org', help='Organization name', required=True) | |
parser.add_argument('--permission', help='Permission ', required=True, | |
choices=['admin', 'maintain', 'pull', 'push', 'triage']) | |
args = parser.parse_args() | |
github = Github(os.environ['GITHUB_TOKEN']) | |
org = github.get_organization(args.org) | |
team = org.get_team_by_slug(args.team) | |
for repo in org.get_repos(): | |
print(f'Adding Team "{args.team}" to repository "{repo.full_name}" with permission "{args.permission}"') | |
team.update_team_repository(repo, args.permission) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Quick and dirty script to give an organization team permission on all organization repositories.
To run: