published on Monday, Mar 9, 2026 by Pulumi
published on Monday, Mar 9, 2026 by Pulumi
Protects a GitHub branch.
The github.BranchProtection resource has moved to the GraphQL API, while this resource will continue to leverage the REST API.
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 System.Collections.Generic;
using Pulumi;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() =>
{
// Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
var example = new Github.BranchProtectionV3("example", new()
{
Repository = github_repository.Example.Name,
Branch = "main",
Restrictions = new Github.Inputs.BranchProtectionV3RestrictionsArgs
{
Users = new[]
{
"foo-user",
},
},
});
});
package main
import (
"github.com/pulumi/pulumi-github/sdk/v4/go/github"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := github.NewBranchProtectionV3(ctx, "example", &github.BranchProtectionV3Args{
Repository: pulumi.Any(github_repository.Example.Name),
Branch: pulumi.String("main"),
Restrictions: &BranchProtectionV3RestrictionsArgs{
Users: pulumi.StringArray{
pulumi.String("foo-user"),
},
},
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.BranchProtectionV3;
import com.pulumi.github.BranchProtectionV3Args;
import com.pulumi.github.inputs.BranchProtectionV3RestrictionsArgs;
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 example = new BranchProtectionV3("example", BranchProtectionV3Args.builder()
.repository(github_repository.example().name())
.branch("main")
.restrictions(BranchProtectionV3RestrictionsArgs.builder()
.users("foo-user")
.build())
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
// Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
const example = new github.BranchProtectionV3("example", {
repository: github_repository.example.name,
branch: "main",
restrictions: {
users: ["foo-user"],
},
});
import pulumi
import pulumi_github as github
# Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
example = github.BranchProtectionV3("example",
repository=github_repository["example"]["name"],
branch="main",
restrictions=github.BranchProtectionV3RestrictionsArgs(
users=["foo-user"],
))
resources:
# Protect the main branch of the foo repository. Only allow a specific user to merge to the branch.
example:
type: github:BranchProtectionV3
properties:
repository: ${github_repository.example.name}
branch: main
restrictions:
users:
- foo-user
using System.Collections.Generic;
using Pulumi;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() =>
{
var exampleRepository = new Github.Repository("exampleRepository");
var exampleTeam = new Github.Team("exampleTeam");
// Protect the main 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 exampleBranchProtectionV3 = new Github.BranchProtectionV3("exampleBranchProtectionV3", new()
{
Repository = exampleRepository.Name,
Branch = "main",
EnforceAdmins = true,
RequiredStatusChecks = new Github.Inputs.BranchProtectionV3RequiredStatusChecksArgs
{
Strict = false,
Contexts = new[]
{
"ci/travis",
},
},
RequiredPullRequestReviews = new Github.Inputs.BranchProtectionV3RequiredPullRequestReviewsArgs
{
DismissStaleReviews = true,
DismissalUsers = new[]
{
"foo-user",
},
DismissalTeams = new[]
{
exampleTeam.Slug,
},
},
Restrictions = new Github.Inputs.BranchProtectionV3RestrictionsArgs
{
Users = new[]
{
"foo-user",
},
Teams = new[]
{
exampleTeam.Slug,
},
Apps = new[]
{
"foo-app",
},
},
});
var exampleTeamRepository = new Github.TeamRepository("exampleTeamRepository", new()
{
TeamId = exampleTeam.Id,
Repository = exampleRepository.Name,
Permission = "pull",
});
});
package main
import (
"github.com/pulumi/pulumi-github/sdk/v4/go/github"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
exampleRepository, err := github.NewRepository(ctx, "exampleRepository", nil)
if err != nil {
return err
}
exampleTeam, err := github.NewTeam(ctx, "exampleTeam", nil)
if err != nil {
return err
}
_, err = github.NewBranchProtectionV3(ctx, "exampleBranchProtectionV3", &github.BranchProtectionV3Args{
Repository: exampleRepository.Name,
Branch: pulumi.String("main"),
EnforceAdmins: pulumi.Bool(true),
RequiredStatusChecks: &BranchProtectionV3RequiredStatusChecksArgs{
Strict: pulumi.Bool(false),
Contexts: pulumi.StringArray{
pulumi.String("ci/travis"),
},
},
RequiredPullRequestReviews: &BranchProtectionV3RequiredPullRequestReviewsArgs{
DismissStaleReviews: pulumi.Bool(true),
DismissalUsers: pulumi.StringArray{
pulumi.String("foo-user"),
},
DismissalTeams: pulumi.StringArray{
exampleTeam.Slug,
},
},
Restrictions: &BranchProtectionV3RestrictionsArgs{
Users: pulumi.StringArray{
pulumi.String("foo-user"),
},
Teams: pulumi.StringArray{
exampleTeam.Slug,
},
Apps: pulumi.StringArray{
pulumi.String("foo-app"),
},
},
})
if err != nil {
return err
}
_, err = github.NewTeamRepository(ctx, "exampleTeamRepository", &github.TeamRepositoryArgs{
TeamId: exampleTeam.ID(),
Repository: exampleRepository.Name,
Permission: pulumi.String("pull"),
})
if err != nil {
return err
}
return nil
})
}
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.Team;
import com.pulumi.github.BranchProtectionV3;
import com.pulumi.github.BranchProtectionV3Args;
import com.pulumi.github.inputs.BranchProtectionV3RequiredStatusChecksArgs;
import com.pulumi.github.inputs.BranchProtectionV3RequiredPullRequestReviewsArgs;
import com.pulumi.github.inputs.BranchProtectionV3RestrictionsArgs;
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");
var exampleTeam = new Team("exampleTeam");
var exampleBranchProtectionV3 = new BranchProtectionV3("exampleBranchProtectionV3", BranchProtectionV3Args.builder()
.repository(exampleRepository.name())
.branch("main")
.enforceAdmins(true)
.requiredStatusChecks(BranchProtectionV3RequiredStatusChecksArgs.builder()
.strict(false)
.contexts("ci/travis")
.build())
.requiredPullRequestReviews(BranchProtectionV3RequiredPullRequestReviewsArgs.builder()
.dismissStaleReviews(true)
.dismissalUsers("foo-user")
.dismissalTeams(exampleTeam.slug())
.build())
.restrictions(BranchProtectionV3RestrictionsArgs.builder()
.users("foo-user")
.teams(exampleTeam.slug())
.apps("foo-app")
.build())
.build());
var exampleTeamRepository = new TeamRepository("exampleTeamRepository", TeamRepositoryArgs.builder()
.teamId(exampleTeam.id())
.repository(exampleRepository.name())
.permission("pull")
.build());
}
}
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const exampleRepository = new github.Repository("exampleRepository", {});
const exampleTeam = new github.Team("exampleTeam", {});
// Protect the main 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.
const exampleBranchProtectionV3 = new github.BranchProtectionV3("exampleBranchProtectionV3", {
repository: exampleRepository.name,
branch: "main",
enforceAdmins: true,
requiredStatusChecks: {
strict: false,
contexts: ["ci/travis"],
},
requiredPullRequestReviews: {
dismissStaleReviews: true,
dismissalUsers: ["foo-user"],
dismissalTeams: [exampleTeam.slug],
},
restrictions: {
users: ["foo-user"],
teams: [exampleTeam.slug],
apps: ["foo-app"],
},
});
const exampleTeamRepository = new github.TeamRepository("exampleTeamRepository", {
teamId: exampleTeam.id,
repository: exampleRepository.name,
permission: "pull",
});
import pulumi
import pulumi_github as github
example_repository = github.Repository("exampleRepository")
example_team = github.Team("exampleTeam")
# Protect the main 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.
example_branch_protection_v3 = github.BranchProtectionV3("exampleBranchProtectionV3",
repository=example_repository.name,
branch="main",
enforce_admins=True,
required_status_checks=github.BranchProtectionV3RequiredStatusChecksArgs(
strict=False,
contexts=["ci/travis"],
),
required_pull_request_reviews=github.BranchProtectionV3RequiredPullRequestReviewsArgs(
dismiss_stale_reviews=True,
dismissal_users=["foo-user"],
dismissal_teams=[example_team.slug],
),
restrictions=github.BranchProtectionV3RestrictionsArgs(
users=["foo-user"],
teams=[example_team.slug],
apps=["foo-app"],
))
example_team_repository = github.TeamRepository("exampleTeamRepository",
team_id=example_team.id,
repository=example_repository.name,
permission="pull")
resources:
# Protect the main 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.
exampleBranchProtectionV3:
type: github:BranchProtectionV3
properties:
repository: ${exampleRepository.name}
branch: main
enforceAdmins: true
requiredStatusChecks:
strict: false
contexts:
- ci/travis
requiredPullRequestReviews:
dismissStaleReviews: true
dismissalUsers:
- foo-user
dismissalTeams:
- ${exampleTeam.slug}
restrictions:
users:
- foo-user
teams:
- ${exampleTeam.slug}
apps:
- foo-app
exampleRepository:
type: github:Repository
exampleTeam:
type: github:Team
exampleTeamRepository:
type: github:TeamRepository
properties:
teamId: ${exampleTeam.id}
repository: ${exampleRepository.name}
permission: pull
Create BranchProtectionV3 Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new BranchProtectionV3(name: string, args: BranchProtectionV3Args, opts?: CustomResourceOptions);@overload
def BranchProtectionV3(resource_name: str,
args: BranchProtectionV3Args,
opts: Optional[ResourceOptions] = None)
@overload
def BranchProtectionV3(resource_name: str,
opts: Optional[ResourceOptions] = None,
branch: Optional[str] = None,
repository: Optional[str] = None,
enforce_admins: Optional[bool] = None,
require_conversation_resolution: Optional[bool] = None,
require_signed_commits: Optional[bool] = None,
required_pull_request_reviews: Optional[BranchProtectionV3RequiredPullRequestReviewsArgs] = None,
required_status_checks: Optional[BranchProtectionV3RequiredStatusChecksArgs] = None,
restrictions: Optional[BranchProtectionV3RestrictionsArgs] = None)func NewBranchProtectionV3(ctx *Context, name string, args BranchProtectionV3Args, opts ...ResourceOption) (*BranchProtectionV3, error)public BranchProtectionV3(string name, BranchProtectionV3Args args, CustomResourceOptions? opts = null)
public BranchProtectionV3(String name, BranchProtectionV3Args args)
public BranchProtectionV3(String name, BranchProtectionV3Args args, CustomResourceOptions options)
type: github:BranchProtectionV3
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args BranchProtectionV3Args
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args BranchProtectionV3Args
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args BranchProtectionV3Args
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BranchProtectionV3Args
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BranchProtectionV3Args
- 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 branchProtectionV3Resource = new Github.BranchProtectionV3("branchProtectionV3Resource", new()
{
Branch = "string",
Repository = "string",
EnforceAdmins = false,
RequireConversationResolution = false,
RequireSignedCommits = false,
RequiredPullRequestReviews = new Github.Inputs.BranchProtectionV3RequiredPullRequestReviewsArgs
{
DismissStaleReviews = false,
DismissalTeams = new[]
{
"string",
},
DismissalUsers = new[]
{
"string",
},
RequireCodeOwnerReviews = false,
RequiredApprovingReviewCount = 0,
},
RequiredStatusChecks = new Github.Inputs.BranchProtectionV3RequiredStatusChecksArgs
{
Contexts = new[]
{
"string",
},
Strict = false,
},
Restrictions = new Github.Inputs.BranchProtectionV3RestrictionsArgs
{
Apps = new[]
{
"string",
},
Teams = new[]
{
"string",
},
Users = new[]
{
"string",
},
},
});
example, err := github.NewBranchProtectionV3(ctx, "branchProtectionV3Resource", &github.BranchProtectionV3Args{
Branch: pulumi.String("string"),
Repository: pulumi.String("string"),
EnforceAdmins: pulumi.Bool(false),
RequireConversationResolution: pulumi.Bool(false),
RequireSignedCommits: pulumi.Bool(false),
RequiredPullRequestReviews: &github.BranchProtectionV3RequiredPullRequestReviewsArgs{
DismissStaleReviews: pulumi.Bool(false),
DismissalTeams: pulumi.StringArray{
pulumi.String("string"),
},
DismissalUsers: pulumi.StringArray{
pulumi.String("string"),
},
RequireCodeOwnerReviews: pulumi.Bool(false),
RequiredApprovingReviewCount: pulumi.Int(0),
},
RequiredStatusChecks: &github.BranchProtectionV3RequiredStatusChecksArgs{
Contexts: pulumi.StringArray{
pulumi.String("string"),
},
Strict: pulumi.Bool(false),
},
Restrictions: &github.BranchProtectionV3RestrictionsArgs{
Apps: pulumi.StringArray{
pulumi.String("string"),
},
Teams: pulumi.StringArray{
pulumi.String("string"),
},
Users: pulumi.StringArray{
pulumi.String("string"),
},
},
})
var branchProtectionV3Resource = new BranchProtectionV3("branchProtectionV3Resource", BranchProtectionV3Args.builder()
.branch("string")
.repository("string")
.enforceAdmins(false)
.requireConversationResolution(false)
.requireSignedCommits(false)
.requiredPullRequestReviews(BranchProtectionV3RequiredPullRequestReviewsArgs.builder()
.dismissStaleReviews(false)
.dismissalTeams("string")
.dismissalUsers("string")
.requireCodeOwnerReviews(false)
.requiredApprovingReviewCount(0)
.build())
.requiredStatusChecks(BranchProtectionV3RequiredStatusChecksArgs.builder()
.contexts("string")
.strict(false)
.build())
.restrictions(BranchProtectionV3RestrictionsArgs.builder()
.apps("string")
.teams("string")
.users("string")
.build())
.build());
branch_protection_v3_resource = github.BranchProtectionV3("branchProtectionV3Resource",
branch="string",
repository="string",
enforce_admins=False,
require_conversation_resolution=False,
require_signed_commits=False,
required_pull_request_reviews={
"dismiss_stale_reviews": False,
"dismissal_teams": ["string"],
"dismissal_users": ["string"],
"require_code_owner_reviews": False,
"required_approving_review_count": 0,
},
required_status_checks={
"contexts": ["string"],
"strict": False,
},
restrictions={
"apps": ["string"],
"teams": ["string"],
"users": ["string"],
})
const branchProtectionV3Resource = new github.BranchProtectionV3("branchProtectionV3Resource", {
branch: "string",
repository: "string",
enforceAdmins: false,
requireConversationResolution: false,
requireSignedCommits: false,
requiredPullRequestReviews: {
dismissStaleReviews: false,
dismissalTeams: ["string"],
dismissalUsers: ["string"],
requireCodeOwnerReviews: false,
requiredApprovingReviewCount: 0,
},
requiredStatusChecks: {
contexts: ["string"],
strict: false,
},
restrictions: {
apps: ["string"],
teams: ["string"],
users: ["string"],
},
});
type: github:BranchProtectionV3
properties:
branch: string
enforceAdmins: false
repository: string
requireConversationResolution: false
requireSignedCommits: false
requiredPullRequestReviews:
dismissStaleReviews: false
dismissalTeams:
- string
dismissalUsers:
- string
requireCodeOwnerReviews: false
requiredApprovingReviewCount: 0
requiredStatusChecks:
contexts:
- string
strict: false
restrictions:
apps:
- string
teams:
- string
users:
- string
BranchProtectionV3 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 BranchProtectionV3 resource accepts the following input properties:
- Branch string
- The Git branch to protect.
- Repository string
- The GitHub repository name.
- Enforce
Admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - Require
Conversation boolResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - Require
Signed boolCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - Required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- Required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- Restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- Branch string
- The Git branch to protect.
- Repository string
- The GitHub repository name.
- Enforce
Admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - Require
Conversation boolResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - Require
Signed boolCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - Required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews Args - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- Required
Status BranchChecks Protection V3Required Status Checks Args - Enforce restrictions for required status checks. See Required Status Checks below for details.
- Restrictions
Branch
Protection V3Restrictions Args - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch String
- The Git branch to protect.
- repository String
- The GitHub repository name.
- enforce
Admins Boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - require
Conversation BooleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed BooleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch string
- The Git branch to protect.
- repository string
- The GitHub repository name.
- enforce
Admins boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - require
Conversation booleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed booleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch str
- The Git branch to protect.
- repository str
- The GitHub repository name.
- enforce_
admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - require_
conversation_ boolresolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require_
signed_ boolcommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required_
pull_ Branchrequest_ reviews Protection V3Required Pull Request Reviews Args - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required_
status_ Branchchecks Protection V3Required Status Checks Args - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions Args - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch String
- The Git branch to protect.
- repository String
- The GitHub repository name.
- enforce
Admins Boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - require
Conversation BooleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed BooleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull Property MapRequest Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status Property MapChecks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions Property Map
- Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Outputs
All input properties are implicitly available as output properties. Additionally, the BranchProtectionV3 resource produces the following output properties:
Look up Existing BranchProtectionV3 Resource
Get an existing BranchProtectionV3 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?: BranchProtectionV3State, opts?: CustomResourceOptions): BranchProtectionV3@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
branch: Optional[str] = None,
enforce_admins: Optional[bool] = None,
etag: Optional[str] = None,
repository: Optional[str] = None,
require_conversation_resolution: Optional[bool] = None,
require_signed_commits: Optional[bool] = None,
required_pull_request_reviews: Optional[BranchProtectionV3RequiredPullRequestReviewsArgs] = None,
required_status_checks: Optional[BranchProtectionV3RequiredStatusChecksArgs] = None,
restrictions: Optional[BranchProtectionV3RestrictionsArgs] = None) -> BranchProtectionV3func GetBranchProtectionV3(ctx *Context, name string, id IDInput, state *BranchProtectionV3State, opts ...ResourceOption) (*BranchProtectionV3, error)public static BranchProtectionV3 Get(string name, Input<string> id, BranchProtectionV3State? state, CustomResourceOptions? opts = null)public static BranchProtectionV3 get(String name, Output<String> id, BranchProtectionV3State state, CustomResourceOptions options)resources: _: type: github:BranchProtectionV3 get: id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Branch string
- The Git branch to protect.
- Enforce
Admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - Etag string
- Repository string
- The GitHub repository name.
- Require
Conversation boolResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - Require
Signed boolCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - Required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- Required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- Restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- Branch string
- The Git branch to protect.
- Enforce
Admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - Etag string
- Repository string
- The GitHub repository name.
- Require
Conversation boolResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - Require
Signed boolCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - Required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews Args - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- Required
Status BranchChecks Protection V3Required Status Checks Args - Enforce restrictions for required status checks. See Required Status Checks below for details.
- Restrictions
Branch
Protection V3Restrictions Args - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch String
- The Git branch to protect.
- enforce
Admins Boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - etag String
- repository String
- The GitHub repository name.
- require
Conversation BooleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed BooleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch string
- The Git branch to protect.
- enforce
Admins boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - etag string
- repository string
- The GitHub repository name.
- require
Conversation booleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed booleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull BranchRequest Reviews Protection V3Required Pull Request Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status BranchChecks Protection V3Required Status Checks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch str
- The Git branch to protect.
- enforce_
admins bool - Boolean, setting this to
trueenforces status checks for repository administrators. - etag str
- repository str
- The GitHub repository name.
- require_
conversation_ boolresolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require_
signed_ boolcommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required_
pull_ Branchrequest_ reviews Protection V3Required Pull Request Reviews Args - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required_
status_ Branchchecks Protection V3Required Status Checks Args - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions
Branch
Protection V3Restrictions Args - Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
- branch String
- The Git branch to protect.
- enforce
Admins Boolean - Boolean, setting this to
trueenforces status checks for repository administrators. - etag String
- repository String
- The GitHub repository name.
- require
Conversation BooleanResolution - Boolean, setting this to
truerequires all conversations on code must be resolved before a pull request can be merged. - require
Signed BooleanCommits - Boolean, setting this to
truerequires all commits to be signed with GPG. - required
Pull Property MapRequest Reviews - Enforce restrictions for pull request reviews. See Required Pull Request Reviews below for details.
- required
Status Property MapChecks - Enforce restrictions for required status checks. See Required Status Checks below for details.
- restrictions Property Map
- Enforce restrictions for the users and teams that may push to the branch. See Restrictions below for details.
Supporting Types
BranchProtectionV3RequiredPullRequestReviews, BranchProtectionV3RequiredPullRequestReviewsArgs
- Dismiss
Stale boolReviews - Dismissal
Teams List<string> - Dismissal
Users List<string> - Include
Admins bool - Require
Code boolOwner Reviews - Required
Approving intReview Count
- Dismiss
Stale boolReviews - Dismissal
Teams []string - Dismissal
Users []string - Include
Admins bool - Require
Code boolOwner Reviews - Required
Approving intReview Count
- dismiss
Stale BooleanReviews - dismissal
Teams List<String> - dismissal
Users List<String> - include
Admins Boolean - require
Code BooleanOwner Reviews - required
Approving IntegerReview Count
- dismiss
Stale booleanReviews - dismissal
Teams string[] - dismissal
Users string[] - include
Admins boolean - require
Code booleanOwner Reviews - required
Approving numberReview Count
- dismiss_
stale_ boolreviews - dismissal_
teams Sequence[str] - dismissal_
users Sequence[str] - include_
admins bool - require_
code_ boolowner_ reviews - required_
approving_ intreview_ count
- dismiss
Stale BooleanReviews - dismissal
Teams List<String> - dismissal
Users List<String> - include
Admins Boolean - require
Code BooleanOwner Reviews - required
Approving NumberReview Count
BranchProtectionV3RequiredStatusChecks, BranchProtectionV3RequiredStatusChecksArgs
- Contexts List<string>
- Include
Admins bool - Strict bool
- Contexts []string
- Include
Admins bool - Strict bool
- contexts List<String>
- include
Admins Boolean - strict Boolean
- contexts string[]
- include
Admins boolean - strict boolean
- contexts Sequence[str]
- include_
admins bool - strict bool
- contexts List<String>
- include
Admins Boolean - strict Boolean
BranchProtectionV3Restrictions, BranchProtectionV3RestrictionsArgs
Import
GitHub Branch Protection can be imported using an ID made up of repository:branch, e.g.
$ pulumi import github:index/branchProtectionV3:BranchProtectionV3 terraform terraform:main
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
githubTerraform Provider.
published on Monday, Mar 9, 2026 by Pulumi
