github_branch_default

Provides a GitHub branch default resource.

This resource allows you to set the default branch for a given repository.

Note that use of this resource is incompatible with the default_branch option of the github_repository resource. Using both will result in plans always showing a diff.

Example Usage

Basic usage:

resource "github_repository" "example" {
  name        = "example"
  description = "My awesome codebase"
  auto_init   = true
}

resource "github_branch" "development" {
  repository = github_repository.example.name
  branch     = "development"
}

resource "github_branch_default" "default"{
  repository = github_repository.example.name
  branch     = github_branch.development.branch
}

Renaming to a branch that doesn't exist:

resource "github_repository" "example" {
  name        = "example"
  description = "My awesome codebase"
  auto_init   = true
}

resource "github_branch_default" "default"{
  repository = github_repository.example.name
  branch     = "development"
  rename     = true
}

Argument Reference

The following arguments are supported:

Import

GitHub Branch Defaults can be imported using an ID made up of repository, e.g.

$ terraform import github_branch_default.branch_default my-repo