Skip to content

feat: add files_branch_source_branch; expand files_branch to create/u… #6

Merged
merged 1 commit into from
Apr 21, 2026
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading