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

Conversation

arnol377
Copy link
Collaborator

@arnol377 arnol377 commented Apr 21, 2026

Summary

Extends the files_branch feature to support an update workflow for existing repositories, and adds a files_branch_source_branch variable so the branch can be created from a specific source ref rather than always defaulting to the repository default branch.

Changes

variables.tf

  • Added files_branch_source_branch (optional string, default null): the source branch used when creating files_branch. When null, falls back to var.github_default_branch via coalesce().

github_branch.tf

  • Removed the && var.create_repo restriction on github_branch.files_branch — the resource now creates the branch for both new repos (create_repo = true) and existing repos (create_repo = false).
  • Changed repository reference from local.repo_name to local.repository_name to align with other resources in the module.
  • Changed source_branch to coalesce(var.files_branch_source_branch, var.github_default_branch) so callers can pass an explicit source ref (e.g. the current default branch of an existing repo).
  • Added data.github_repository.existing to depends_on so branch creation waits for the existing-repo data source in update mode.
  • Added lifecycle { ignore_changes = [source_branch, source_sha] } to prevent Terraform from re-creating the branch on subsequent applies.

Motivation

This change is required by SCT-Engineering/terraform-eks-deployment#16, which implements a repository_mode = "update" workflow. In update mode no new repository is created, so the previous && var.create_repo condition meant files_branch was never created. The caller now passes:

files_branch               = "update/<cluster-name>"
files_branch_source_branch = "<existing-repo-default-branch>"

and the module handles branch creation before committing any managed files.

Testing

  • terraform validate passes against the module root.
  • Tested end-to-end via terraform-eks-deployment workspace targeting an existing EKS cluster repo in SCT-Engineering.

@arnol377 arnol377 merged commit de58a14 into main Apr 21, 2026
1 check failed
@arnol377 arnol377 deleted the feat/files-branch-source-branch branch April 21, 2026 18:45
Sign in to join this conversation on GitHub.
Labels
None yet
Projects
None yet
1 participant