BranchProtection

class BranchProtection : KotlinCustomResource

Example Usage

package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.Repository;
import com.pulumi.github.GithubFunctions;
import com.pulumi.github.inputs.GetUserArgs;
import com.pulumi.github.Team;
import com.pulumi.github.BranchProtection;
import com.pulumi.github.BranchProtectionArgs;
import com.pulumi.github.inputs.BranchProtectionRequiredStatusCheckArgs;
import com.pulumi.github.inputs.BranchProtectionRequiredPullRequestReviewArgs;
import com.pulumi.github.TeamRepository;
import com.pulumi.github.TeamRepositoryArgs;
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) {
var exampleRepository = new Repository("exampleRepository");
final var exampleUser = GithubFunctions.getUser(GetUserArgs.builder()
.username("example")
.build());
var exampleTeam = new Team("exampleTeam");
var exampleBranchProtection = new BranchProtection("exampleBranchProtection", BranchProtectionArgs.builder()
.repositoryId(exampleRepository.nodeId())
.pattern("main")
.enforceAdmins(true)
.allowsDeletions(true)
.requiredStatusChecks(BranchProtectionRequiredStatusCheckArgs.builder()
.strict(false)
.contexts("ci/travis")
.build())
.requiredPullRequestReviews(BranchProtectionRequiredPullRequestReviewArgs.builder()
.dismissStaleReviews(true)
.restrictDismissals(true)
.dismissalRestrictions(
exampleUser.applyValue(getUserResult -> getUserResult.nodeId()),
exampleTeam.nodeId(),
"/exampleuser",
"exampleorganization/exampleteam")
.build())
.pushRestrictions(
exampleUser.applyValue(getUserResult -> getUserResult.nodeId()),
"/exampleuser",
"exampleorganization/exampleteam")
.forcePushBypassers(
exampleUser.applyValue(getUserResult -> getUserResult.nodeId()),
"/exampleuser",
"exampleorganization/exampleteam")
.build());
var exampleTeamRepository = new TeamRepository("exampleTeamRepository", TeamRepositoryArgs.builder()
.teamId(exampleTeam.id())
.repository(exampleRepository.name())
.permission("pull")
.build());
}
}

Import

GitHub Branch Protection can be imported using an ID made up of repository:pattern, e.g.

$ pulumi import github:index/branchProtection:BranchProtection terraform terraform:main

Properties

Link copied to clipboard
val allowsDeletions: Output<Boolean>?

Boolean, setting this to true to allow the branch to be deleted.

Link copied to clipboard

Boolean, setting this to true to allow force pushes on the branch.

Link copied to clipboard
val blocksCreations: Output<Boolean>?

Boolean, setting this to true to block creating the branch.

Link copied to clipboard
val enforceAdmins: Output<Boolean>?

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

Link copied to clipboard

The list of actor Names/IDs that are allowed to bypass force push restrictions. Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.

Link copied to clipboard
val id: Output<String>
Link copied to clipboard
val lockBranch: Output<Boolean>?

Boolean, Setting this to true will make the branch read-only and preventing any pushes to it. Defaults to false

Link copied to clipboard
val pattern: Output<String>

Identifies the protection rule pattern.

Link copied to clipboard
val pulumiChildResources: Set<KotlinResource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The list of actor Names/IDs that may push to the branch. Actor names must either begin with a "/" for users or the organization name followed by a "/" for teams.

Link copied to clipboard
val repositoryId: Output<String>

The name or node ID of the repository associated with this branch protection rule.

Link copied to clipboard

Boolean, setting this to true requires all conversations on code must be resolved before a pull request can be merged.

Link copied to clipboard

Boolean, setting this to true enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard
val urn: Output<String>