github.Branch
Explore with Pulumi AI
This resource allows you to create and manage branches within your repository.
Additional constraints can be applied to ensure your branch is created from another branch or commit.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as github from "@pulumi/github";
const development = new github.Branch("development", {
repository: "example",
branch: "development",
});
import pulumi
import pulumi_github as github
development = github.Branch("development",
repository="example",
branch="development")
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.NewBranch(ctx, "development", &github.BranchArgs{
Repository: pulumi.String("example"),
Branch: pulumi.String("development"),
})
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 development = new Github.Branch("development", new()
{
Repository = "example",
BranchName = "development",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.github.Branch;
import com.pulumi.github.BranchArgs;
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 development = new Branch("development", BranchArgs.builder()
.repository("example")
.branch("development")
.build());
}
}
resources:
development:
type: github:Branch
properties:
repository: example
branch: development
Create Branch Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Branch(name: string, args: BranchArgs, opts?: CustomResourceOptions);
@overload
def Branch(resource_name: str,
args: BranchArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Branch(resource_name: str,
opts: Optional[ResourceOptions] = None,
branch: Optional[str] = None,
repository: Optional[str] = None,
source_branch: Optional[str] = None,
source_sha: Optional[str] = None)
func NewBranch(ctx *Context, name string, args BranchArgs, opts ...ResourceOption) (*Branch, error)
public Branch(string name, BranchArgs args, CustomResourceOptions? opts = null)
public Branch(String name, BranchArgs args)
public Branch(String name, BranchArgs args, CustomResourceOptions options)
type: github:Branch
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 BranchArgs
- 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 BranchArgs
- 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 BranchArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args BranchArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args BranchArgs
- 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 branchResource = new Github.Branch("branchResource", new()
{
BranchName = "string",
Repository = "string",
SourceBranch = "string",
SourceSha = "string",
});
example, err := github.NewBranch(ctx, "branchResource", &github.BranchArgs{
Branch: pulumi.String("string"),
Repository: pulumi.String("string"),
SourceBranch: pulumi.String("string"),
SourceSha: pulumi.String("string"),
})
var branchResource = new Branch("branchResource", BranchArgs.builder()
.branch("string")
.repository("string")
.sourceBranch("string")
.sourceSha("string")
.build());
branch_resource = github.Branch("branchResource",
branch="string",
repository="string",
source_branch="string",
source_sha="string")
const branchResource = new github.Branch("branchResource", {
branch: "string",
repository: "string",
sourceBranch: "string",
sourceSha: "string",
});
type: github:Branch
properties:
branch: string
repository: string
sourceBranch: string
sourceSha: string
Branch Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The Branch resource accepts the following input properties:
- Branch
Name string - The repository branch to create.
- Repository string
- The GitHub repository name.
- Source
Branch string - The branch name to start from. Defaults to
main
. - Source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- Branch string
- The repository branch to create.
- Repository string
- The GitHub repository name.
- Source
Branch string - The branch name to start from. Defaults to
main
. - Source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch String
- The repository branch to create.
- repository String
- The GitHub repository name.
- source
Branch String - The branch name to start from. Defaults to
main
. - source
Sha String - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch string
- The repository branch to create.
- repository string
- The GitHub repository name.
- source
Branch string - The branch name to start from. Defaults to
main
. - source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch str
- The repository branch to create.
- repository str
- The GitHub repository name.
- source_
branch str - The branch name to start from. Defaults to
main
. - source_
sha str - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch String
- The repository branch to create.
- repository String
- The GitHub repository name.
- source
Branch String - The branch name to start from. Defaults to
main
. - source
Sha String - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
Outputs
All input properties are implicitly available as output properties. Additionally, the Branch resource produces the following output properties:
Look up Existing Branch Resource
Get an existing Branch 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?: BranchState, opts?: CustomResourceOptions): Branch
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
branch: Optional[str] = None,
etag: Optional[str] = None,
ref: Optional[str] = None,
repository: Optional[str] = None,
sha: Optional[str] = None,
source_branch: Optional[str] = None,
source_sha: Optional[str] = None) -> Branch
func GetBranch(ctx *Context, name string, id IDInput, state *BranchState, opts ...ResourceOption) (*Branch, error)
public static Branch Get(string name, Input<string> id, BranchState? state, CustomResourceOptions? opts = null)
public static Branch get(String name, Output<String> id, BranchState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- 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
Name string - The repository branch to create.
- Etag string
- An etag representing the Branch object.
- Ref string
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - Repository string
- The GitHub repository name.
- Sha string
- A string storing the reference's
HEAD
commit's SHA1. - Source
Branch string - The branch name to start from. Defaults to
main
. - Source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- Branch string
- The repository branch to create.
- Etag string
- An etag representing the Branch object.
- Ref string
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - Repository string
- The GitHub repository name.
- Sha string
- A string storing the reference's
HEAD
commit's SHA1. - Source
Branch string - The branch name to start from. Defaults to
main
. - Source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch String
- The repository branch to create.
- etag String
- An etag representing the Branch object.
- ref String
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - repository String
- The GitHub repository name.
- sha String
- A string storing the reference's
HEAD
commit's SHA1. - source
Branch String - The branch name to start from. Defaults to
main
. - source
Sha String - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch string
- The repository branch to create.
- etag string
- An etag representing the Branch object.
- ref string
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - repository string
- The GitHub repository name.
- sha string
- A string storing the reference's
HEAD
commit's SHA1. - source
Branch string - The branch name to start from. Defaults to
main
. - source
Sha string - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch str
- The repository branch to create.
- etag str
- An etag representing the Branch object.
- ref str
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - repository str
- The GitHub repository name.
- sha str
- A string storing the reference's
HEAD
commit's SHA1. - source_
branch str - The branch name to start from. Defaults to
main
. - source_
sha str - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
- branch String
- The repository branch to create.
- etag String
- An etag representing the Branch object.
- ref String
- A string representing a branch reference, in the form of
refs/heads/<branch>
. - repository String
- The GitHub repository name.
- sha String
- A string storing the reference's
HEAD
commit's SHA1. - source
Branch String - The branch name to start from. Defaults to
main
. - source
Sha String - The commit hash to start from. Defaults to the tip of
source_branch
. If provided,source_branch
is ignored.
Import
GitHub Branch can be imported using an ID made up of repository:branch
, e.g.
$ pulumi import github:index/branch:Branch terraform terraform:main
Importing github branch into an instance object (when using a for each block to manage multiple branches)
$ pulumi import github:index/branch:Branch terraform["terraform"] terraform:main
Optionally, a source branch may be specified using an ID of repository:branch:source_branch
.
This is useful for importing branches that do not branch directly off main.
$ pulumi import github:index/branch:Branch terraform terraform:feature-branch:dev
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
github
Terraform Provider.