From e55ca159ea0addda890aec02d6e64e910ddf6f33 Mon Sep 17 00:00:00 2001 From: Kazik Pogoda Date: Sat, 23 Sep 2023 21:26:12 +0200 Subject: [PATCH] all the remaining variables + branch_protection config --- repository/main.tf | 27 +++++++++++++++----- repository/variables.tf | 55 ++++++++++++++++++++++++++++++----------- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/repository/main.tf b/repository/main.tf index 6b98c21..127e237 100644 --- a/repository/main.tf +++ b/repository/main.tf @@ -12,10 +12,25 @@ provider "github" { } resource github_repository this { - name = var.repository - description = var.description - vulnerability_alerts = true - has_wiki = false + name = var.name + description = var.description + vulnerability_alerts = true + homepage_url = var.homepage_url + visibility = var.private ? "private" : "public" + has_issues = var.has_issues + has_discussions = var.has_discussions + has_projects = var.has_projects + has_wiki = var.has_wiki + has_downloads = false + allow_merge_commit = false + allow_squash_merge = true + allow_rebase_merge = false + allow_auto_merge = false + delete_branch_on_merge = true + auto_init = true + license_template = var.license_template + allow_update_branch = true + topics = var.topics dynamic "pages" { for_each = var.pages_url != null ? [1] : [] content { @@ -39,7 +54,7 @@ resource github_branch_protection main { force_push_bypassers = [] lock_branch = false push_restrictions = [] - require_conversation_resolution = false + require_conversation_resolution = true require_signed_commits = false - required_linear_history = false + required_linear_history = true } diff --git a/repository/variables.tf b/repository/variables.tf index dcf767d..f348df7 100644 --- a/repository/variables.tf +++ b/repository/variables.tf @@ -1,28 +1,28 @@ variable "owner" { - type = string description = "GitHub user/organization containing the repository" + type = string } -variable "repository" { - type = string +variable "name" { description = "GitHub repository name" + type = string } variable "description" { - type = string description = "Repository description" + type = string } variable "private" { - type = bool description = "Is this a private repository (public by default)" - default = false + type = bool + default = false } variable "homepage_url" { - type = string - description = "URL of a page describing the project." - default = null + description = "URL of a page describing the project" + type = string + default = null } variable "pages_url" { @@ -31,13 +31,38 @@ variable "pages_url" { default = null } -variable "has_downloads" { - type = bool - default = false +variable "has_issues" { + description = "Set to `true` to enable the GitHub Issues features on the repository" + type = bool + default = false } -variable "has_issues" { - type = bool - default = false +variable "has_discussions" { + description = "Set to `true` to enable GitHub Discussions on the repository" + type = bool + default = false +} + +variable "has_projects" { + description = " Set to `true` to enable the GitHub Projects features on the repository. Per the GitHub documentation when in an organization that has disabled repository projects it will default to false and will otherwise default to true. If you specify true when it has been disabled it will return an error." + type = bool + default = false } +variable "has_wiki" { + description = " Set to true to enable the GitHub Wiki features on the repository." + type = bool + default = false +} + +variable "license_template" { + description = "Use the [name of the template](https://github.com/github/choosealicense.com/tree/gh-pages/_licenses) without the extension. For example, \"mit\" or \"mpl-2.0\"." + type = string + default = null +} + +variable "topics" { + description = "The list of topics of the repository" + type = list(string) + default = null +}