1. Packages
  2. Github Provider
  3. API Docs
  4. RepositoryCollaborator
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.RepositoryCollaborator

Explore with Pulumi AI

Provides a GitHub repository collaborator resource.

Note: github.RepositoryCollaborator cannot be used in conjunction with github.RepositoryCollaborators or they will fight over what your policy should be.

This resource allows you to add/remove collaborators from 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 collaborator on a repository. When destroyed, either the invitation will be cancelled or the collaborator will be removed from the repository.

This resource is non-authoritative, for managing ALL collaborators of a repo, use github.RepositoryCollaborators instead.

Further documentation on GitHub collaborators:

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

// Add a collaborator to a repository
const aRepoCollaborator = new github.RepositoryCollaborator("a_repo_collaborator", {
    repository: "our-cool-repo",
    username: "SomeUser",
    permission: "admin",
});
Copy
import pulumi
import pulumi_github as github

# Add a collaborator to a repository
a_repo_collaborator = github.RepositoryCollaborator("a_repo_collaborator",
    repository="our-cool-repo",
    username="SomeUser",
    permission="admin")
Copy
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 a collaborator to a repository
		_, err := github.NewRepositoryCollaborator(ctx, "a_repo_collaborator", &github.RepositoryCollaboratorArgs{
			Repository: pulumi.String("our-cool-repo"),
			Username:   pulumi.String("SomeUser"),
			Permission: pulumi.String("admin"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;

return await Deployment.RunAsync(() => 
{
    // Add a collaborator to a repository
    var aRepoCollaborator = new Github.RepositoryCollaborator("a_repo_collaborator", new()
    {
        Repository = "our-cool-repo",
        Username = "SomeUser",
        Permission = "admin",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.RepositoryCollaborator;
import com.pulumi.github.RepositoryCollaboratorArgs;
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 a collaborator to a repository
        var aRepoCollaborator = new RepositoryCollaborator("aRepoCollaborator", RepositoryCollaboratorArgs.builder()
            .repository("our-cool-repo")
            .username("SomeUser")
            .permission("admin")
            .build());

    }
}
Copy
resources:
  # Add a collaborator to a repository
  aRepoCollaborator:
    type: github:RepositoryCollaborator
    name: a_repo_collaborator
    properties:
      repository: our-cool-repo
      username: SomeUser
      permission: admin
Copy

Create RepositoryCollaborator Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new RepositoryCollaborator(name: string, args: RepositoryCollaboratorArgs, opts?: CustomResourceOptions);
@overload
def RepositoryCollaborator(resource_name: str,
                           args: RepositoryCollaboratorArgs,
                           opts: Optional[ResourceOptions] = None)

@overload
def RepositoryCollaborator(resource_name: str,
                           opts: Optional[ResourceOptions] = None,
                           repository: Optional[str] = None,
                           username: Optional[str] = None,
                           permission: Optional[str] = None,
                           permission_diff_suppression: Optional[bool] = None)
func NewRepositoryCollaborator(ctx *Context, name string, args RepositoryCollaboratorArgs, opts ...ResourceOption) (*RepositoryCollaborator, error)
public RepositoryCollaborator(string name, RepositoryCollaboratorArgs args, CustomResourceOptions? opts = null)
public RepositoryCollaborator(String name, RepositoryCollaboratorArgs args)
public RepositoryCollaborator(String name, RepositoryCollaboratorArgs args, CustomResourceOptions options)
type: github:RepositoryCollaborator
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. RepositoryCollaboratorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. RepositoryCollaboratorArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. RepositoryCollaboratorArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. RepositoryCollaboratorArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. RepositoryCollaboratorArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var repositoryCollaboratorResource = new Github.RepositoryCollaborator("repositoryCollaboratorResource", new()
{
    Repository = "string",
    Username = "string",
    Permission = "string",
    PermissionDiffSuppression = false,
});
Copy
example, err := github.NewRepositoryCollaborator(ctx, "repositoryCollaboratorResource", &github.RepositoryCollaboratorArgs{
	Repository:                pulumi.String("string"),
	Username:                  pulumi.String("string"),
	Permission:                pulumi.String("string"),
	PermissionDiffSuppression: pulumi.Bool(false),
})
Copy
var repositoryCollaboratorResource = new RepositoryCollaborator("repositoryCollaboratorResource", RepositoryCollaboratorArgs.builder()
    .repository("string")
    .username("string")
    .permission("string")
    .permissionDiffSuppression(false)
    .build());
Copy
repository_collaborator_resource = github.RepositoryCollaborator("repositoryCollaboratorResource",
    repository="string",
    username="string",
    permission="string",
    permission_diff_suppression=False)
Copy
const repositoryCollaboratorResource = new github.RepositoryCollaborator("repositoryCollaboratorResource", {
    repository: "string",
    username: "string",
    permission: "string",
    permissionDiffSuppression: false,
});
Copy
type: github:RepositoryCollaborator
properties:
    permission: string
    permissionDiffSuppression: false
    repository: string
    username: string
Copy

RepositoryCollaborator Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The RepositoryCollaborator resource accepts the following input properties:

Repository
This property is required.
Changes to this property will trigger replacement.
string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

Username
This property is required.
Changes to this property will trigger replacement.
string
The user to add to the repository as a collaborator.
Permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
PermissionDiffSuppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
Repository
This property is required.
Changes to this property will trigger replacement.
string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

Username
This property is required.
Changes to this property will trigger replacement.
string
The user to add to the repository as a collaborator.
Permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
PermissionDiffSuppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
repository
This property is required.
Changes to this property will trigger replacement.
String

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username
This property is required.
Changes to this property will trigger replacement.
String
The user to add to the repository as a collaborator.
permission Changes to this property will trigger replacement. String
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression Boolean
Suppress plan diffs for triage and maintain. Defaults to false.
repository
This property is required.
Changes to this property will trigger replacement.
string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username
This property is required.
Changes to this property will trigger replacement.
string
The user to add to the repository as a collaborator.
permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression boolean
Suppress plan diffs for triage and maintain. Defaults to false.
repository
This property is required.
Changes to this property will trigger replacement.
str

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username
This property is required.
Changes to this property will trigger replacement.
str
The user to add to the repository as a collaborator.
permission Changes to this property will trigger replacement. str
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permission_diff_suppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
repository
This property is required.
Changes to this property will trigger replacement.
String

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username
This property is required.
Changes to this property will trigger replacement.
String
The user to add to the repository as a collaborator.
permission Changes to this property will trigger replacement. String
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression Boolean
Suppress plan diffs for triage and maintain. Defaults to false.

Outputs

All input properties are implicitly available as output properties. Additionally, the RepositoryCollaborator resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
InvitationId string
ID of the invitation to be used in github.UserInvitationAccepter
Id string
The provider-assigned unique ID for this managed resource.
InvitationId string
ID of the invitation to be used in github.UserInvitationAccepter
id String
The provider-assigned unique ID for this managed resource.
invitationId String
ID of the invitation to be used in github.UserInvitationAccepter
id string
The provider-assigned unique ID for this managed resource.
invitationId string
ID of the invitation to be used in github.UserInvitationAccepter
id str
The provider-assigned unique ID for this managed resource.
invitation_id str
ID of the invitation to be used in github.UserInvitationAccepter
id String
The provider-assigned unique ID for this managed resource.
invitationId String
ID of the invitation to be used in github.UserInvitationAccepter

Look up Existing RepositoryCollaborator Resource

Get an existing RepositoryCollaborator resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: RepositoryCollaboratorState, opts?: CustomResourceOptions): RepositoryCollaborator
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        invitation_id: Optional[str] = None,
        permission: Optional[str] = None,
        permission_diff_suppression: Optional[bool] = None,
        repository: Optional[str] = None,
        username: Optional[str] = None) -> RepositoryCollaborator
func GetRepositoryCollaborator(ctx *Context, name string, id IDInput, state *RepositoryCollaboratorState, opts ...ResourceOption) (*RepositoryCollaborator, error)
public static RepositoryCollaborator Get(string name, Input<string> id, RepositoryCollaboratorState? state, CustomResourceOptions? opts = null)
public static RepositoryCollaborator get(String name, Output<String> id, RepositoryCollaboratorState state, CustomResourceOptions options)
resources:  _:    type: github:RepositoryCollaborator    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
InvitationId string
ID of the invitation to be used in github.UserInvitationAccepter
Permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
PermissionDiffSuppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
Repository Changes to this property will trigger replacement. string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

Username Changes to this property will trigger replacement. string
The user to add to the repository as a collaborator.
InvitationId string
ID of the invitation to be used in github.UserInvitationAccepter
Permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
PermissionDiffSuppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
Repository Changes to this property will trigger replacement. string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

Username Changes to this property will trigger replacement. string
The user to add to the repository as a collaborator.
invitationId String
ID of the invitation to be used in github.UserInvitationAccepter
permission Changes to this property will trigger replacement. String
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression Boolean
Suppress plan diffs for triage and maintain. Defaults to false.
repository Changes to this property will trigger replacement. String

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username Changes to this property will trigger replacement. String
The user to add to the repository as a collaborator.
invitationId string
ID of the invitation to be used in github.UserInvitationAccepter
permission Changes to this property will trigger replacement. string
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression boolean
Suppress plan diffs for triage and maintain. Defaults to false.
repository Changes to this property will trigger replacement. string

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username Changes to this property will trigger replacement. string
The user to add to the repository as a collaborator.
invitation_id str
ID of the invitation to be used in github.UserInvitationAccepter
permission Changes to this property will trigger replacement. str
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permission_diff_suppression bool
Suppress plan diffs for triage and maintain. Defaults to false.
repository Changes to this property will trigger replacement. str

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username Changes to this property will trigger replacement. str
The user to add to the repository as a collaborator.
invitationId String
ID of the invitation to be used in github.UserInvitationAccepter
permission Changes to this property will trigger replacement. String
The permission of the outside collaborator for the repository. Must be one of pull, push, maintain, triage or admin or the name of an existing custom repository role within the organization for organization-owned repositories. Must be push for personal repositories. Defaults to push.
permissionDiffSuppression Boolean
Suppress plan diffs for triage and maintain. Defaults to false.
repository Changes to this property will trigger replacement. String

The GitHub repository

Note: The owner of the repository can be passed as part of the repository name e.g. owner-org-name/repo-name. If owner is not supplied as part of the repository name, it may also be supplied by setting the environment variable GITHUB_OWNER.

username Changes to this property will trigger replacement. String
The user to add to the repository as a collaborator.

Import

GitHub Repository Collaborators can be imported using an ID made up of repository:username, e.g.

$ pulumi import github:index/repositoryCollaborator:RepositoryCollaborator collaborator terraform:someuser
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.