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

github.getBranch

Explore with Pulumi AI

GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi

Use this data source to retrieve information about a repository branch.

Example Usage

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

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

development = github.get_branch(repository="example",
    branch="development")
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.LookupBranch(ctx, &github.LookupBranchArgs{
			Repository: "example",
			Branch:     "development",
		}, 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 development = Github.GetBranch.Invoke(new()
    {
        Repository = "example",
        Branch = "development",
    });

});
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.GetBranchArgs;
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 development = GithubFunctions.getBranch(GetBranchArgs.builder()
            .repository("example")
            .branch("development")
            .build());

    }
}
Copy
variables:
  development:
    fn::invoke:
      function: github:getBranch
      arguments:
        repository: example
        branch: development
Copy

Using getBranch

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 getBranch(args: GetBranchArgs, opts?: InvokeOptions): Promise<GetBranchResult>
function getBranchOutput(args: GetBranchOutputArgs, opts?: InvokeOptions): Output<GetBranchResult>
Copy
def get_branch(branch: Optional[str] = None,
               repository: Optional[str] = None,
               opts: Optional[InvokeOptions] = None) -> GetBranchResult
def get_branch_output(branch: Optional[pulumi.Input[str]] = None,
               repository: Optional[pulumi.Input[str]] = None,
               opts: Optional[InvokeOptions] = None) -> Output[GetBranchResult]
Copy
func LookupBranch(ctx *Context, args *LookupBranchArgs, opts ...InvokeOption) (*LookupBranchResult, error)
func LookupBranchOutput(ctx *Context, args *LookupBranchOutputArgs, opts ...InvokeOption) LookupBranchResultOutput
Copy

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

public static class GetBranch 
{
    public static Task<GetBranchResult> InvokeAsync(GetBranchArgs args, InvokeOptions? opts = null)
    public static Output<GetBranchResult> Invoke(GetBranchInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetBranchResult> getBranch(GetBranchArgs args, InvokeOptions options)
public static Output<GetBranchResult> getBranch(GetBranchArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: github:index/getBranch:getBranch
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Branch
This property is required.
Changes to this property will trigger replacement.
string
The repository branch to retrieve.
Repository
This property is required.
Changes to this property will trigger replacement.
string
The GitHub repository name.
Branch
This property is required.
Changes to this property will trigger replacement.
string
The repository branch to retrieve.
Repository
This property is required.
Changes to this property will trigger replacement.
string
The GitHub repository name.
branch
This property is required.
Changes to this property will trigger replacement.
String
The repository branch to retrieve.
repository
This property is required.
Changes to this property will trigger replacement.
String
The GitHub repository name.
branch
This property is required.
Changes to this property will trigger replacement.
string
The repository branch to retrieve.
repository
This property is required.
Changes to this property will trigger replacement.
string
The GitHub repository name.
branch
This property is required.
Changes to this property will trigger replacement.
str
The repository branch to retrieve.
repository
This property is required.
Changes to this property will trigger replacement.
str
The GitHub repository name.
branch
This property is required.
Changes to this property will trigger replacement.
String
The repository branch to retrieve.
repository
This property is required.
Changes to this property will trigger replacement.
String
The GitHub repository name.

getBranch Result

The following output properties are available:

Branch string
Etag string
An etag representing the Branch object.
Id string
The provider-assigned unique ID for this managed resource.
Ref string
A string representing a branch reference, in the form of refs/heads/<branch>.
Repository string
Sha string
A string storing the reference's HEAD commit's SHA1.
Branch string
Etag string
An etag representing the Branch object.
Id string
The provider-assigned unique ID for this managed resource.
Ref string
A string representing a branch reference, in the form of refs/heads/<branch>.
Repository string
Sha string
A string storing the reference's HEAD commit's SHA1.
branch String
etag String
An etag representing the Branch object.
id String
The provider-assigned unique ID for this managed resource.
ref String
A string representing a branch reference, in the form of refs/heads/<branch>.
repository String
sha String
A string storing the reference's HEAD commit's SHA1.
branch string
etag string
An etag representing the Branch object.
id string
The provider-assigned unique ID for this managed resource.
ref string
A string representing a branch reference, in the form of refs/heads/<branch>.
repository string
sha string
A string storing the reference's HEAD commit's SHA1.
branch str
etag str
An etag representing the Branch object.
id str
The provider-assigned unique ID for this managed resource.
ref str
A string representing a branch reference, in the form of refs/heads/<branch>.
repository str
sha str
A string storing the reference's HEAD commit's SHA1.
branch String
etag String
An etag representing the Branch object.
id String
The provider-assigned unique ID for this managed resource.
ref String
A string representing a branch reference, in the form of refs/heads/<branch>.
repository String
sha String
A string storing the reference's HEAD commit's SHA1.

Package Details

Repository
GitHub pulumi/pulumi-github
License
Apache-2.0
Notes
This Pulumi package is based on the github Terraform Provider.
GitHub v6.7.0 published on Friday, Feb 28, 2025 by Pulumi