| layout | github |
|---|---|
| page_title | GitHub: github_repository_collaborators |
| description | Provides a GitHub repository collaborators resource. |
Provides a GitHub repository collaborators resource.
~> Note: github_repository_collaborators cannot be used in conjunction with github_repository_collaborator and github_team_repository or they will fight over what your policy should be.
This resource allows you to manage all collaborators for repositories in your organization or personal account. For organization repositories, collaborators can have explicit (and differing levels of) read, write, or administrator access to specific repositories, without giving the user full organization membership. For personal repositories, collaborators can only be granted write (implicitly includes read) permission.
When applied, an invitation will be sent to the user to become a collaborators on a repository. When destroyed, either the invitation will be cancelled or the collaborators will be removed from the repository.
~> Note on Archived Repositories: When a repository is archived, GitHub makes it read-only, preventing collaborator modifications. If you attempt to destroy resources associated with archived repositories, the provider will gracefully handle the operation by logging an informational message and removing the resource from Terraform state without attempting to modify the archived repository.
This resource is authoritative. For adding a collaborator to a repo in a non-authoritative manner, use github_repository_collaborator instead.
Further documentation on GitHub collaborators:
- Adding outside collaborators to your personal repositories
- Adding outside collaborators to repositories in your organization
- Converting an organization member to an outside collaborators
# Add collaborators to a repository
resource "github_team" "some_team" {
name = "SomeTeam"
description = "Some cool team"
}
resource "github_repository" "some_repo" {
name = "some-repo"
}
resource "github_repository_collaborators" "some_repo_collaborators" {
repository = github_repository.some_repo.name
user {
permission = "admin"
username = "SomeUser"
}
team {
permission = "pull"
team_id = github_team.some_team.slug
}
}The following arguments are supported:
repository- (Required) The GitHub repository.user- (Optional) List of users to grant access to the repository.team- (Optional) List of teams to grant access to the repository.ignore_team- (Optional) List of teams to ignore when checking for repository access. This supports ignoring teams granted access at an organizational level.
The user block supports:
username- (Required) The user to add to the repository as a collaborator.permission- (Optional) The permission of the outside collaborators for the repository. Must be one ofpull,push,maintain,triageoradminor the name of an existing custom repository role within the organization for organization-owned repositories. Must bepushfor personal repositories. Defaults topush.
The team block supports:
team_id- (Required) The GitHub team id or the GitHub team slug.permission- (Optional) The permission of the outside collaborators for the repository. Must be one ofpull,triage,push,maintain,adminor the name of an existing custom repository role within the organisation. Defaults topush.
The ignore_team block supports:
team_id- (Required) The GitHub team id or the GitHub team slug.
In addition to the above arguments, the following attributes are exported:
invitation_ids- Map of usernames to invitation ID for any users added as part of creation of this resource to be used ingithub_user_invitation_accepter.
GitHub Repository Collaborators can be imported using the repository name name, e.g.
terraform import github_repository_collaborators.collaborators myrepo