RepositoryCollaborators

class RepositoryCollaborators : KotlinCustomResource

Provides a GitHub repository collaborators resource.

Note: github.RepositoryCollaborators cannot be used in conjunction with github.RepositoryCollaborator and github.TeamRepository 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. This resource is authoritative. For adding a collaborator to a repo in a non-authoritative manner, use github.RepositoryCollaborator instead. Further documentation on GitHub collaborators:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
// Add collaborators to a repository
const someTeam = new github.Team("some_team", {
name: "SomeTeam",
description: "Some cool team",
});
const someRepo = new github.Repository("some_repo", {name: "some-repo"});
const someRepoCollaborators = new github.RepositoryCollaborators("some_repo_collaborators", {
repository: someRepo.name,
users: [{
permission: "admin",
username: "SomeUser",
}],
teams: [{
permission: "pull",
teamId: someTeam.slug,
}],
});
import pulumi
import pulumi_github as github
# Add collaborators to a repository
some_team = github.Team("some_team",
name="SomeTeam",
description="Some cool team")
some_repo = github.Repository("some_repo", name="some-repo")
some_repo_collaborators = github.RepositoryCollaborators("some_repo_collaborators",
repository=some_repo.name,
users=[{
"permission": "admin",
"username": "SomeUser",
}],
teams=[{
"permission": "pull",
"team_id": some_team.slug,
}])
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() =>
{
// Add collaborators to a repository
var someTeam = new Github.Team("some_team", new()
{
Name = "SomeTeam",
Description = "Some cool team",
});
var someRepo = new Github.Repository("some_repo", new()
{
Name = "some-repo",
});
var someRepoCollaborators = new Github.RepositoryCollaborators("some_repo_collaborators", new()
{
Repository = someRepo.Name,
Users = new[]
{
new Github.Inputs.RepositoryCollaboratorsUserArgs
{
Permission = "admin",
Username = "SomeUser",
},
},
Teams = new[]
{
new Github.Inputs.RepositoryCollaboratorsTeamArgs
{
Permission = "pull",
TeamId = someTeam.Slug,
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-github/sdk/v6/go/github"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
// Add collaborators to a repository
someTeam, err := github.NewTeam(ctx, "some_team", &github.TeamArgs{
Name: pulumi.String("SomeTeam"),
Description: pulumi.String("Some cool team"),
})
if err != nil {
return err
}
someRepo, err := github.NewRepository(ctx, "some_repo", &github.RepositoryArgs{
Name: pulumi.String("some-repo"),
})
if err != nil {
return err
}
_, err = github.NewRepositoryCollaborators(ctx, "some_repo_collaborators", &github.RepositoryCollaboratorsArgs{
Repository: someRepo.Name,
Users: github.RepositoryCollaboratorsUserArray{
&github.RepositoryCollaboratorsUserArgs{
Permission: pulumi.String("admin"),
Username: pulumi.String("SomeUser"),
},
},
Teams: github.RepositoryCollaboratorsTeamArray{
&github.RepositoryCollaboratorsTeamArgs{
Permission: pulumi.String("pull"),
TeamId: someTeam.Slug,
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.Team;
import com.pulumi.github.TeamArgs;
import com.pulumi.github.Repository;
import com.pulumi.github.RepositoryArgs;
import com.pulumi.github.RepositoryCollaborators;
import com.pulumi.github.RepositoryCollaboratorsArgs;
import com.pulumi.github.inputs.RepositoryCollaboratorsUserArgs;
import com.pulumi.github.inputs.RepositoryCollaboratorsTeamArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
// Add collaborators to a repository
var someTeam = new Team("someTeam", TeamArgs.builder()
.name("SomeTeam")
.description("Some cool team")
.build());
var someRepo = new Repository("someRepo", RepositoryArgs.builder()
.name("some-repo")
.build());
var someRepoCollaborators = new RepositoryCollaborators("someRepoCollaborators", RepositoryCollaboratorsArgs.builder()
.repository(someRepo.name())
.users(RepositoryCollaboratorsUserArgs.builder()
.permission("admin")
.username("SomeUser")
.build())
.teams(RepositoryCollaboratorsTeamArgs.builder()
.permission("pull")
.teamId(someTeam.slug())
.build())
.build());
}
}
resources:
# Add collaborators to a repository
someTeam:
type: github:Team
name: some_team
properties:
name: SomeTeam
description: Some cool team
someRepo:
type: github:Repository
name: some_repo
properties:
name: some-repo
someRepoCollaborators:
type: github:RepositoryCollaborators
name: some_repo_collaborators
properties:
repository: ${someRepo.name}
users:
- permission: admin
username: SomeUser
teams:
- permission: pull
teamId: ${someTeam.slug}

Import

GitHub Repository Collaborators can be imported using the name name, e.g.

$ pulumi import github:index/repositoryCollaborators:RepositoryCollaborators collaborators terraform

Properties

Link copied to clipboard
val id: Output<String>
Link copied to clipboard

List of teams to ignore when checking for repository access. This supports ignoring teams granted access at an organizational level.

Link copied to clipboard

Map of usernames to invitation ID for any users added as part of creation of this resource to be used in github.UserInvitationAccepter.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val repository: Output<String>

The GitHub repository.

Link copied to clipboard

List of teams to grant access to the repository.

Link copied to clipboard
val urn: Output<String>
Link copied to clipboard

List of users to grant access to the repository.