diff --git a/README.md b/README.md index 09bd44d..9913f60 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # GitHub Organization as Code -GitHub organization managed as code. +GitHub organization managed as code. Implements a GitOps workflow to transform a YAML - declarative GitHub organization definition into GitHub resources, automating configuration of repositories. ## Features @@ -107,10 +107,19 @@ Create the configuration file: --- repositories: - name: repo-slug + # Metadata description: "The repository description." # OPTIONAL, DEFAULT none homepage_url: https://example.com/ # OPTIONAL, DEFAULT none topics: # OPTIONAL, DEFAULT none - some-topic + - another-topic + # Properties + is_template: true # OPTIONAL, DEFAULT false + # Contents + template: # OPTIONAL, DEFAULT none + owner: bruzit + repository: template + include_all_branches: true # OPTIONAL, DEFAULT false ``` Set it as source of truth: diff --git a/terraform/main.tf b/terraform/main.tf index 289efde..c14b9e4 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -11,4 +11,21 @@ resource "github_repository" "this" { description = try(each.value.description, null) homepage_url = try(each.value.homepage_url, null) topics = try(each.value.topics, null) + + # Properties + is_template = try(each.value.is_template, null) + + # Contents + dynamic "template" { + for_each = ( + try(each.value.template, null) != null && + length(try(each.value.template, {})) > 0 + ) ? [each.value.template] : [] + + content { + owner = template.value.owner + repository = template.value.repository + include_all_branches = try(template.value.include_all_branches, false) + } + } } diff --git a/test.yaml b/test.yaml index 6184241..f17379b 100644 --- a/test.yaml +++ b/test.yaml @@ -1,8 +1,18 @@ --- repositories: - name: .github - description: "BruzIT Test organization profile and management." + description: "BruzIT Test organization profile and repository management." topics: - - github-organization-profile - github-profile - github-profile-readme + - github-organization-profile + - github-organization-management + - name: template + description: "Standardized repository scaffold for BruzIT projects. Pre-configured with semantic-release, license boilerplate, README structure, and initial v0.0.0 tag." + topics: + - repository-template + is_template: true + - name: template-use + template: + owner: bruzit-test + repository: template