1. Packages
  2. Github Provider
  3. API Docs
  4. getBranchProtectionRules
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

github.getBranchProtectionRules

Explore with Pulumi AI

Use this data source to retrieve a list of repository branch protection rules.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";

const example = github.getBranchProtectionRules({
    repository: "example",
});
Copy
import pulumi
import pulumi_github as github

example = github.get_branch_protection_rules(repository="example")
Copy
package main

import (
	"github.com/pulumi/pulumi-github/sdk/v6/go/github"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := github.GetBranchProtectionRules(ctx, &github.GetBranchProtectionRulesArgs{
			Repository: "example",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;

return await Deployment.RunAsync(() => 
{
    var example = Github.GetBranchProtectionRules.Invoke(new()
    {
        Repository = "example",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.GithubFunctions;
import com.pulumi.github.inputs.GetBranchProtectionRulesArgs;
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) {
        final var example = GithubFunctions.getBranchProtectionRules(GetBranchProtectionRulesArgs.builder()
            .repository("example")
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: github:getBranchProtectionRules
      arguments:
        repository: example
Copy

Using getBranchProtectionRules

Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

function getBranchProtectionRules(args: GetBranchProtectionRulesArgs, opts?: InvokeOptions): Promise<GetBranchProtectionRulesResult>
function getBranchProtectionRulesOutput(args: GetBranchProtectionRulesOutputArgs, opts?: InvokeOptions): Output<GetBranchProtectionRulesResult>
Copy
def get_branch_protection_rules(repository: Optional[str] = None,
                                opts: Optional[InvokeOptions] = None) -> GetBranchProtectionRulesResult
def get_branch_protection_rules_output(repository: Optional[pulumi.Input[str]] = None,
                                opts: Optional[InvokeOptions] = None) -> Output[GetBranchProtectionRulesResult]
Copy
func GetBranchProtectionRules(ctx *Context, args *GetBranchProtectionRulesArgs, opts ...InvokeOption) (*GetBranchProtectionRulesResult, error)
func GetBranchProtectionRulesOutput(ctx *Context, args *GetBranchProtectionRulesOutputArgs, opts ...InvokeOption) GetBranchProtectionRulesResultOutput
Copy

> Note: This function is named GetBranchProtectionRules in the Go SDK.

public static class GetBranchProtectionRules 
{
    public static Task<GetBranchProtectionRulesResult> InvokeAsync(GetBranchProtectionRulesArgs args, InvokeOptions? opts = null)
    public static Output<GetBranchProtectionRulesResult> Invoke(GetBranchProtectionRulesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBranchProtectionRulesResult> getBranchProtectionRules(GetBranchProtectionRulesArgs args, InvokeOptions options)
public static Output<GetBranchProtectionRulesResult> getBranchProtectionRules(GetBranchProtectionRulesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: github:index/getBranchProtectionRules:getBranchProtectionRules
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Repository This property is required. string
The GitHub repository name.
Repository This property is required. string
The GitHub repository name.
repository This property is required. String
The GitHub repository name.
repository This property is required. string
The GitHub repository name.
repository This property is required. str
The GitHub repository name.
repository This property is required. String
The GitHub repository name.

getBranchProtectionRules Result

The following output properties are available:

Id string
The provider-assigned unique ID for this managed resource.
Repository string
Rules List<GetBranchProtectionRulesRule>
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:
Id string
The provider-assigned unique ID for this managed resource.
Repository string
Rules []GetBranchProtectionRulesRule
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:
id String
The provider-assigned unique ID for this managed resource.
repository String
rules List<GetBranchProtectionRulesRule>
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:
id string
The provider-assigned unique ID for this managed resource.
repository string
rules GetBranchProtectionRulesRule[]
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:
id str
The provider-assigned unique ID for this managed resource.
repository str
rules Sequence[GetBranchProtectionRulesRule]
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:
id String
The provider-assigned unique ID for this managed resource.
repository String
rules List<Property Map>
Collection of Branch Protection Rules. Each of the results conforms to the following scheme:

Supporting Types

GetBranchProtectionRulesRule

Pattern This property is required. string
Identifies the protection rule pattern.
Pattern This property is required. string
Identifies the protection rule pattern.
pattern This property is required. String
Identifies the protection rule pattern.
pattern This property is required. string
Identifies the protection rule pattern.
pattern This property is required. str
Identifies the protection rule pattern.
pattern This property is required. String
Identifies the protection rule pattern.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.