From 278f18161d4c37774520f53961b36bd52906920a Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Mon, 24 Oct 2022 17:48:35 -0700 Subject: fix(ops/github): create resources in correct order We first need to create a repository before we can create the default branch. For the default branch to be set, we also need the repository to contain a commit, which is achieved with the `auto_init' attribute. We can always push with `--force' to overwrite that initial commit when doing the migration. --- ops/github/repositories.tf | 2 ++ 1 file changed, 2 insertions(+) (limited to 'ops') diff --git a/ops/github/repositories.tf b/ops/github/repositories.tf index ba5cf60..38e5de2 100644 --- a/ops/github/repositories.tf +++ b/ops/github/repositories.tf @@ -18,9 +18,11 @@ resource "github_repository" "repos" { allow_rebase_merge = false vulnerability_alerts = try(each.value.vulnerability_alerts, false) delete_branch_on_merge = try(!each.value.archived, true) + auto_init = true } resource "github_branch_default" "main" { + depends_on = [github_repository.repos] # no need to set the default branch if the repository is already # archived. # use the name for the repository if set -- cgit 1.4.1