Show / Hide Table of Contents

Class BranchProtection

Protects a GitHub branch.

This resource allows you to configure branch protection for repositories in your organization. When applied, the branch will be protected from forced pushes and deletion. Additional constraints, such as required status checks or restrictions on users, teams, and apps, can also be configured.

Example Usage

using Pulumi;
using Github = Pulumi.Github;

class MyStack : Stack
{
public MyStack()
{
    var exampleTeam = new Github.Team("exampleTeam", new Github.TeamArgs
    {
    });
    // Protect the master branch of the foo repository. Additionally, require that
    // the "ci/travis" context to be passing and only allow the engineers team merge
    // to the branch.
    var exampleBranchProtection = new Github.BranchProtection("exampleBranchProtection", new Github.BranchProtectionArgs
    {
        Branch = "master",
        EnforceAdmins = true,
        Repository = github_repository.Example.Name,
        RequiredPullRequestReviews = new Github.Inputs.BranchProtectionRequiredPullRequestReviewsArgs
        {
            DismissStaleReviews = true,
            DismissalTeams = 
            {
                exampleTeam.Slug,
                github_team.Second.Slug,
            },
            DismissalUsers = 
            {
                "foo-user",
            },
        },
        RequiredStatusChecks = new Github.Inputs.BranchProtectionRequiredStatusChecksArgs
        {
            Contexts = 
            {
                "ci/travis",
            },
            Strict = false,
        },
        Restrictions = new Github.Inputs.BranchProtectionRestrictionsArgs
        {
            Apps = 
            {
                "foo-app",
            },
            Teams = 
            {
                exampleTeam.Slug,
            },
            Users = 
            {
                "foo-user",
            },
        },
    });
    var exampleTeamRepository = new Github.TeamRepository("exampleTeamRepository", new Github.TeamRepositoryArgs
    {
        Permission = "pull",
        Repository = github_repository.Example.Name,
        TeamId = exampleTeam.Id,
    });
}

}
Inheritance
System.Object
Resource
CustomResource
BranchProtection
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Github
Assembly: Pulumi.Github.dll
Syntax
public class BranchProtection : CustomResource

Constructors

View Source

BranchProtection(String, BranchProtectionArgs, CustomResourceOptions)

Create a BranchProtection resource with the given unique name, arguments, and options.

Declaration
public BranchProtection(string name, BranchProtectionArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

BranchProtectionArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Branch

The Git branch to protect.

Declaration
public Output<string> Branch { get; }
Property Value
Type Description
Output<System.String>
View Source

EnforceAdmins

Boolean, setting this to true enforces status checks for repository administrators.

Declaration
public Output<bool?> EnforceAdmins { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Etag

Declaration
public Output<string> Etag { get; }
Property Value
Type Description
Output<System.String>
View Source

Repository

The GitHub repository name.

Declaration
public Output<string> Repository { get; }
Property Value
Type Description
Output<System.String>
View Source

RequiredPullRequestReviews

Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.

Declaration
public Output<BranchProtectionRequiredPullRequestReviews> RequiredPullRequestReviews { get; }
Property Value
Type Description
Output<BranchProtectionRequiredPullRequestReviews>
View Source

RequiredStatusChecks

Enforce restrictions for required status checks. See Required Status Checks below for details.

Declaration
public Output<BranchProtectionRequiredStatusChecks> RequiredStatusChecks { get; }
Property Value
Type Description
Output<BranchProtectionRequiredStatusChecks>
View Source

RequireSignedCommits

Boolean, setting this to true requires all commits to be signed with GPG.

Declaration
public Output<bool?> RequireSignedCommits { get; }
Property Value
Type Description
Output<System.Nullable<System.Boolean>>
View Source

Restrictions

Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.

Declaration
public Output<BranchProtectionRestrictions> Restrictions { get; }
Property Value
Type Description
Output<BranchProtectionRestrictions>

Methods

View Source

Get(String, Input<String>, BranchProtectionState, CustomResourceOptions)

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

Declaration
public static BranchProtection Get(string name, Input<string> id, BranchProtectionState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

BranchProtectionState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
BranchProtection
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.