Skip to content

GCSS-14: support non-main default branch on repo creation#50

Closed
pavlovic-ivan wants to merge 1 commit into
mainfrom
fix-default-branch-issue
Closed

GCSS-14: support non-main default branch on repo creation#50
pavlovic-ivan wants to merge 1 commit into
mainfrom
fix-default-branch-issue

Conversation

@pavlovic-ivan

Copy link
Copy Markdown
Contributor

Closes #14

Problem

When a new repo is created via the importer with a non-main default branch (e.g. master, develop), the freshly auto-init'd GitHub repo lands with main as the default. Subsequent applies don't fix it, because the terraform module didn't issue a rename, so the configured default_branch was silently ignored.

Fix

In the vendored terraform-github-repository module, set rename = true on github_branch_default when default_branch != "main", so the freshly created main is renamed to the configured default on first apply.

ignore_changes on rename is added so subsequent applies don't re-issue the rename — the GitHub provider rejects "renaming a branch to itself", which would fail every apply after the first one and on every existing repo whose default branch is already correct.

Notes

  • Net diff: 5 lines added in feature/github-repo-provisioning/modules/terraform-github-repository/main.tf.
  • Also removes a now-obsolete feature/github-repo-provisioning/gcss_config/.gitkeep placeholder.

Set rename = true on github_branch_default when default_branch is not "main"
so a freshly auto-init'd repo's main branch gets renamed to the configured
default. Use ignore_changes on rename to avoid re-issuing the rename API
call on subsequent applies, which would fail for existing repos whose
default branch is already set (the provider rejects renaming a branch to
itself).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[GCSS] Creating default master branch fails

1 participant