BranchProtectionArgs

data class BranchProtectionArgs(val allowsDeletions: Output<Boolean>? = null, val allowsForcePushes: Output<Boolean>? = null, val blocksCreations: Output<Boolean>? = null, val enforceAdmins: Output<Boolean>? = null, val forcePushBypassers: Output<List<String>>? = null, val lockBranch: Output<Boolean>? = null, val pattern: Output<String>? = null, val pushRestrictions: Output<List<String>>? = null, val repositoryId: Output<String>? = null, val requireConversationResolution: Output<Boolean>? = null, val requireSignedCommits: Output<Boolean>? = null, val requiredLinearHistory: Output<Boolean>? = null, val requiredPullRequestReviews: Output<List<BranchProtectionRequiredPullRequestReviewArgs>>? = null, val requiredStatusChecks: Output<List<BranchProtectionRequiredStatusCheckArgs>>? = null) : ConvertibleToJava<BranchProtectionArgs>

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

Constructors

Link copied to clipboard
constructor(allowsDeletions: Output<Boolean>? = null, allowsForcePushes: Output<Boolean>? = null, blocksCreations: Output<Boolean>? = null, enforceAdmins: Output<Boolean>? = null, forcePushBypassers: Output<List<String>>? = null, lockBranch: Output<Boolean>? = null, pattern: Output<String>? = null, pushRestrictions: Output<List<String>>? = null, repositoryId: Output<String>? = null, requireConversationResolution: Output<Boolean>? = null, requireSignedCommits: Output<Boolean>? = null, requiredLinearHistory: Output<Boolean>? = null, requiredPullRequestReviews: Output<List<BranchProtectionRequiredPullRequestReviewArgs>>? = null, requiredStatusChecks: Output<List<BranchProtectionRequiredStatusCheckArgs>>? = null)

Properties

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

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

Link copied to clipboard
val allowsForcePushes: Output<Boolean>? = null

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

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

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

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

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

Link copied to clipboard
val forcePushBypassers: Output<List<String>>? = null

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 lockBranch: Output<Boolean>? = null

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>? = null

Identifies the protection rule pattern.

Link copied to clipboard
val pushRestrictions: Output<List<String>>? = null

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>? = null

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
val requiredLinearHistory: Output<Boolean>? = null

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
val requireSignedCommits: Output<Boolean>? = null

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

Functions

Link copied to clipboard
open override fun toJava(): BranchProtectionArgs