Skip to content

Commit

Permalink
feat: add files_branch_source_branch; expand files_branch to create/u…
Browse files Browse the repository at this point in the history
…pdate mode
  • Loading branch information
Dave Arnold committed Apr 21, 2026
1 parent 7e088f3 commit c38143c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
19 changes: 13 additions & 6 deletions github_branch.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,22 @@ resource "github_branch_default" "default_main_branch" {
]
}

# For new repos: create files_branch inside the module after repo exists.
# For existing repos: files_branch is created externally (in terraform-eks-deployment) before the module runs.
# Create files_branch for both new repos (create_repo=true) and existing repos (create_repo=false).
# source_branch can be customized via files_branch_source_branch; defaults to the repo default branch.
resource "github_branch" "files_branch" {
count = var.files_branch != null && var.create_repo ? 1 : 0
repository = local.repo_name
count = var.files_branch != null ? 1 : 0
repository = local.repository_name
branch = var.files_branch
source_branch = var.github_default_branch
source_branch = coalesce(var.files_branch_source_branch, var.github_default_branch)

depends_on = [github_repository.repo]
depends_on = [
github_repository.repo,
data.github_repository.existing,
]

lifecycle {
ignore_changes = [source_branch, source_sha]
}
}

data "github_user" "pull_request_bypassers" {
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ variable "files_branch" {
default = null
}

variable "files_branch_source_branch" {
description = "Source branch to create files_branch from. If null, the repository default branch is used. Only has effect when files_branch is set."
type = string
default = null
}

variable "github_required_approving_review_count" {
description = "Number of approvals needed for pull requests"
type = number
Expand Down

0 comments on commit c38143c

Please sign in to comment.