GCSS-14: support non-main default branch on repo creation#50
Closed
pavlovic-ivan wants to merge 1 commit into
Closed
GCSS-14: support non-main default branch on repo creation#50pavlovic-ivan wants to merge 1 commit into
pavlovic-ivan wants to merge 1 commit into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #14
Problem
When a new repo is created via the importer with a non-
maindefault branch (e.g.master,develop), the freshly auto-init'd GitHub repo lands withmainas the default. Subsequent applies don't fix it, because the terraform module didn't issue a rename, so the configureddefault_branchwas silently ignored.Fix
In the vendored
terraform-github-repositorymodule, setrename = trueongithub_branch_defaultwhendefault_branch != "main", so the freshly createdmainis renamed to the configured default on first apply.ignore_changesonrenameis 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
feature/github-repo-provisioning/modules/terraform-github-repository/main.tf.feature/github-repo-provisioning/gcss_config/.gitkeepplaceholder.