GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi
github.getRepositoryBranches
Explore with Pulumi AI
Use this data source to retrieve information about branches in a repository.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const example = github.getRepositoryBranches({
    repository: "example-repository",
});
import pulumi
import pulumi_github as github
example = github.get_repository_branches(repository="example-repository")
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.GetRepositoryBranches(ctx, &github.GetRepositoryBranchesArgs{
			Repository: "example-repository",
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Github = Pulumi.Github;
return await Deployment.RunAsync(() => 
{
    var example = Github.GetRepositoryBranches.Invoke(new()
    {
        Repository = "example-repository",
    });
});
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.GetRepositoryBranchesArgs;
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.getRepositoryBranches(GetRepositoryBranchesArgs.builder()
            .repository("example-repository")
            .build());
    }
}
variables:
  example:
    fn::invoke:
      function: github:getRepositoryBranches
      arguments:
        repository: example-repository
Using getRepositoryBranches
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 getRepositoryBranches(args: GetRepositoryBranchesArgs, opts?: InvokeOptions): Promise<GetRepositoryBranchesResult>
function getRepositoryBranchesOutput(args: GetRepositoryBranchesOutputArgs, opts?: InvokeOptions): Output<GetRepositoryBranchesResult>def get_repository_branches(only_non_protected_branches: Optional[bool] = None,
                            only_protected_branches: Optional[bool] = None,
                            repository: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetRepositoryBranchesResult
def get_repository_branches_output(only_non_protected_branches: Optional[pulumi.Input[bool]] = None,
                            only_protected_branches: Optional[pulumi.Input[bool]] = None,
                            repository: Optional[pulumi.Input[str]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetRepositoryBranchesResult]func GetRepositoryBranches(ctx *Context, args *GetRepositoryBranchesArgs, opts ...InvokeOption) (*GetRepositoryBranchesResult, error)
func GetRepositoryBranchesOutput(ctx *Context, args *GetRepositoryBranchesOutputArgs, opts ...InvokeOption) GetRepositoryBranchesResultOutput> Note: This function is named GetRepositoryBranches in the Go SDK.
public static class GetRepositoryBranches 
{
    public static Task<GetRepositoryBranchesResult> InvokeAsync(GetRepositoryBranchesArgs args, InvokeOptions? opts = null)
    public static Output<GetRepositoryBranchesResult> Invoke(GetRepositoryBranchesInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetRepositoryBranchesResult> getRepositoryBranches(GetRepositoryBranchesArgs args, InvokeOptions options)
public static Output<GetRepositoryBranchesResult> getRepositoryBranches(GetRepositoryBranchesArgs args, InvokeOptions options)
fn::invoke:
  function: github:index/getRepositoryBranches:getRepositoryBranches
  arguments:
    # arguments dictionaryThe following arguments are supported:
- Repository string
- Name of the repository to retrieve the branches from.
- OnlyNon boolProtected Branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- OnlyProtected boolBranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
- Repository string
- Name of the repository to retrieve the branches from.
- OnlyNon boolProtected Branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- OnlyProtected boolBranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
- repository String
- Name of the repository to retrieve the branches from.
- onlyNon BooleanProtected Branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- onlyProtected BooleanBranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
- repository string
- Name of the repository to retrieve the branches from.
- onlyNon booleanProtected Branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- onlyProtected booleanBranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
- repository str
- Name of the repository to retrieve the branches from.
- only_non_ boolprotected_ branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- only_protected_ boolbranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
- repository String
- Name of the repository to retrieve the branches from.
- onlyNon BooleanProtected Branches 
- . If true, the branchesattributes will be populated only with non protected branches. Default:false.
- onlyProtected BooleanBranches 
- . If true, the branchesattributes will be populated only with protected branches. Default:false.
getRepositoryBranches Result
The following output properties are available:
- Branches
List<GetRepository Branches Branch> 
- The list of this repository's branches. Each element of brancheshas the following attributes:
- Id string
- The provider-assigned unique ID for this managed resource.
- Repository string
- OnlyNon boolProtected Branches 
- OnlyProtected boolBranches 
- Branches
[]GetRepository Branches Branch 
- The list of this repository's branches. Each element of brancheshas the following attributes:
- Id string
- The provider-assigned unique ID for this managed resource.
- Repository string
- OnlyNon boolProtected Branches 
- OnlyProtected boolBranches 
- branches
List<GetRepository Branches Branch> 
- The list of this repository's branches. Each element of brancheshas the following attributes:
- id String
- The provider-assigned unique ID for this managed resource.
- repository String
- onlyNon BooleanProtected Branches 
- onlyProtected BooleanBranches 
- branches
GetRepository Branches Branch[] 
- The list of this repository's branches. Each element of brancheshas the following attributes:
- id string
- The provider-assigned unique ID for this managed resource.
- repository string
- onlyNon booleanProtected Branches 
- onlyProtected booleanBranches 
- branches
Sequence[GetRepository Branches Branch] 
- The list of this repository's branches. Each element of brancheshas the following attributes:
- id str
- The provider-assigned unique ID for this managed resource.
- repository str
- only_non_ boolprotected_ branches 
- only_protected_ boolbranches 
- branches List<Property Map>
- The list of this repository's branches. Each element of brancheshas the following attributes:
- id String
- The provider-assigned unique ID for this managed resource.
- repository String
- onlyNon BooleanProtected Branches 
- onlyProtected BooleanBranches 
Supporting Types
GetRepositoryBranchesBranch   
- name String
- Name of the branch.
- protected_ Boolean
- Whether the branch is protected.
Package Details
- Repository
- GitHub pulumi/pulumi-github
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the githubTerraform Provider.