Branch Protection Args
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
Properties
Boolean, setting this to true
to allow the branch to be deleted.
Boolean, setting this to true
to allow force pushes on the branch.
Boolean, setting this to true
to block creating the branch.
Boolean, setting this to true
enforces status checks for repository administrators.
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.
Boolean, Setting this to true
will make the branch read-only and preventing any pushes to it. Defaults to false
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.
The name or node ID of the repository associated with this branch protection rule.
Boolean, setting this to true
requires all conversations on code must be resolved before a pull request can be merged.
Boolean, setting this to true
enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch
Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
Enforce restrictions for required status checks. See Required Status Checks below for details.
Boolean, setting this to true
requires all commits to be signed with GPG.