Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,21 +155,40 @@ The GitHub organization YAML configuration post a Terraform plan as a pull reque
```yaml
---
default-properties: # OPTIONAL
visibility: public # OPTIONAL
has_issues: true # OPTIONAL
has_discussions: true # OPTIONAL
has_projects: true # OPTIONAL
has_wiki: true # OPTIONAL
# Global properties
visibility: public # OPTIONAL, DEFAULT public
# Global features
has_issues: true # OPTIONAL, DEFAULT false
has_discussions: true # OPTIONAL, DEFAULT false
has_projects: true # OPTIONAL, DEFAULT false
has_wiki: true # OPTIONAL, DEFAULT false
# Global settings
allow_merge_commit: false # OPTIONAL, DEFAULT true
allow_squash_merge: true # OPTIONAL, DEFAULT true
allow_rebase_merge: true # OPTIONAL, DEFAULT true
allow_auto_merge: true # OPTIONAL, DEFAULT false
delete_branch_on_merge: true # OPTIONAL, DEFAULT false
repositories:
- name: repo-slug
description: Repository description. # OPTIONAL
topics: # OPTIONAL
# Repository metadata
description: Repository description. # OPTIONAL, DEFAULT none
homepage_url: http://repo.domain/ # OPTIONAL, DEFAULT none
topics: # OPTIONAL, DEFAULT none
- github-topic-1
visibility: public # OPTIONAL
has_issues: true # OPTIONAL
has_discussions: true # OPTIONAL
has_projects: true # OPTIONAL
has_wiki: true # OPTIONAL
# Repository properties
visibility: public # OPTIONAL, DEFAULT public
is_template: true # OPTIONAL, DEFAULT false
# Repository features
has_issues: true # OPTIONAL, DEFAULT false
has_discussions: true # OPTIONAL, DEFAULT false
has_projects: true # OPTIONAL, DEFAULT false
has_wiki: true # OPTIONAL, DEFAULT false
# Repository settings
allow_merge_commit: false # OPTIONAL, DEFAULT true
allow_squash_merge: true # OPTIONAL, DEFAULT true
allow_rebase_merge: true # OPTIONAL, DEFAULT true
allow_auto_merge: true # OPTIONAL, DEFAULT false
delete_branch_on_merge: true # OPTIONAL, DEFAULT false
```

Defaults are the same as in the Terraform provider `github` resource `github_repository`, see [Terraform Registry / Providers / integrations / github / resources / github_repository](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository#argument-reference).
Expand Down
22 changes: 18 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,27 @@ locals {

resource "github_repository" "repo" {
for_each = { for repo in local.repositories : repo.name => repo }
name = each.value.name

description = try(each.value.description, null)
topics = try(each.value.topics, null)
visibility = try(each.value.visibility, local.default_properties.visibility, null)
# Metadata
name = each.value.name
description = try(each.value.description, null)
homepage_url = try(each.value.homepage_url, null)
topics = try(each.value.topics, null)

# Properties
visibility = try(each.value.visibility, local.default_properties.visibility, null)
is_template = try(each.value.is_template, null)

# Features
has_issues = try(each.value.has_issues, local.default_properties.has_issues, null)
has_discussions = try(each.value.has_discussions, local.default_properties.has_discussions, null)
has_projects = try(each.value.has_projects, local.default_properties.has_projects, null)
has_wiki = try(each.value.has_wiki, local.default_properties.has_wiki, null)

# Settings
allow_merge_commit = try(each.value.allow_merge_commit, local.default_properties.allow_merge_commit, null)
allow_squash_merge = try(each.value.allow_squash_merge, local.default_properties.allow_squash_merge, null)
allow_rebase_merge = try(each.value.allow_rebase_merge, local.default_properties.allow_rebase_merge, null)
allow_auto_merge = try(each.value.allow_auto_merge, local.default_properties.allow_auto_merge, null)
delete_branch_on_merge = try(each.value.delete_branch_on_merge, local.default_properties.delete_branch_on_merge, null)
}
10 changes: 10 additions & 0 deletions test.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
---
default-properties:
# Global features
has_issues: true
repositories:
- name: .github
# Repository metadata
description: Xebis Test organization profile.
topics:
- github-organization-profile
- github-profile
- github-profile-readme
# Repository settings
allow_merge_commit: false
allow_squash_merge: true
allow_rebase_merge: true
allow_auto_merge: true
delete_branch_on_merge: true