Reputation: 45
I have build a repository of codes named XYZ on github. I want to share my repository with the entire organization (more the 250 members). For that, I have to add all the members one by one which makes the task tedious.
Is there any simpler way to share this repository with only read access to multiple users at once? Note: This git account is at the organizational level it's not personal account so it should be limited up to our organization
Upvotes: 2
Views: 1550
Reputation: 501
It's function to invite the user to repo. you can change the permission levels.
from github import Github
import json
token = ""
g = Github(token)
def get_org(org_name="org_name"):
""" Get organization
Args:
org_name: Name of organization
Returns:
org: Organization object
"""
return g.get_organization(org_name)
class InviteUser:
def __init__(self):
self.org = None
def invite_user_to_repo(self, user_name, repo_name="Getting-Started"):
""" Invite user to repository
Args:
user_name: Name of user
repo_name: Name of repository
Returns:
None
"""
if self.org is None:
self.org = get_org()
repo = self.org.get_repo(repo_name)
user = g.get_user(user_name)
repo.add_to_collaborators(user, permission="push")
Upvotes: 0
Reputation: 8497
Since you wish to give read permissions to everyone in your GitHub organization, you can do this by setting "Base Permissions" under "Member Privileges" in the organization account settings to "Read".
Reference: Setting base permissions for an organization
Upvotes: 1