diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27f4708..3b9d8a0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
+## [0.18.0]
+
+### Changed
+
+- BREAKING: update to provider `>= 4.31` for supporting default squash and merge commit titles and messages
+
+### Added
+
+- Add support for `squash_merge_commit_title`
+- Add support for `squash_merge_commit_message`
+- Add support for `merge_commit_title`
+- Add support for `merge_commit_message`
+- Add support for `ignore_vulnerability_alerts_during_read`
+
## [0.17.0]
### Added
@@ -385,7 +399,8 @@ Please review plans and report regressions and issues asap so we can improve doc
- This is the initial release of our GitHub Repository module with support for
creating and managing GitHub Repositories for Organizations.
-[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.17.0...HEAD
+[unreleased]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.18.0...HEAD
+[0.18.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.17.0...v0.18.0
[0.17.0]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.16.2...v0.17.0
[0.16.2]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.16.1...v0.16.2
[0.16.1]: https://github.com/mineiros-io/terraform-github-repository/compare/v0.16.0...v0.16.1
diff --git a/README.md b/README.md
index df15cc4..c614484 100644
--- a/README.md
+++ b/README.md
@@ -3,18 +3,18 @@
[](https://github.com/mineiros-io/terraform-github-repository/actions)
[](https://github.com/mineiros-io/terraform-github-repository/releases)
[](https://github.com/hashicorp/terraform/releases)
-[](https://github.com/terraform-providers/terraform-provider-github/releases)
+[](https://github.com/terraform-providers/terraform-provider-github/releases)
[](https://join.slack.com/t/mineiros-community/shared_invite/zt-ehidestg-aLGoIENLVs6tvwJ11w9WGg)
# terraform-github-repository
A [Terraform] module for creating a public or private repository on [Github].
-**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.20 and above from `integrations/github`._**
+**_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.31 and above from `integrations/github`._**
**Attention: This module is incompatible with the Hashicorp GitHub Provider! The latest version of this module supporting `hashicorp/github` provider is `~> 0.10.0`**
-** Note: Versions 5.3.0, 5.4.0, and 5.5.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
+** Note: Versions 5.3.0, 5.4.0, 5.5.0, and 5.6.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
- [GitHub as Code](#github-as-code)
@@ -89,7 +89,8 @@ features like Branch Protection or Collaborator Management.
Teams,
Deploy Keys,
Projects,
- Repository Webhooks
+ Repository Webhooks,
+ GitHub App Installations
- _Features not yet implemented_:
Project Columns support,
@@ -103,7 +104,7 @@ Most basic usage creating a new private github repository.
```hcl
module "repository" {
source = "mineiros-io/repository/github"
- version = "~> 0.16.0"
+ version = "~> 0.18.0"
name = "terraform-github-repository"
license_template = "apache-2.0"
@@ -147,18 +148,28 @@ See [variables.tf] and [examples/] for details and use-cases.
`has_issues`,
`has_projects`,
`has_wiki`,
+ `has_downloads`,
+ `delete_branch_on_merge`,
+ `is_template`,
`allow_merge_commit`,
`allow_rebase_merge`,
`allow_squash_merge`,
`allow_auto_merge`,
- `has_downloads`,
`auto_init`,
`gitignore_template`,
`license_template`,
+ `squash_merge_commit_title`,
+ `squash_merge_commit_message`,
+ `merge_commit_title`,
+ `merge_commit_message`,
+ `auto_init`,
`default_branch`,
`topics`,
`issue_labels_create`,
- `issue_labels_merge_with_github_labels`.
+ `issue_labels_merge_with_github_labels`,
+ `vulnerability_alerts`,
+ `ignore_vulnerability_alerts_during_read`,
+ `template`.
Module defaults are used for all arguments that are not set in `defaults`.
Using top level arguments override defaults set by this argument.
@@ -216,6 +227,30 @@ See [variables.tf] and [examples/] for details and use-cases.
Default is `false`.
+- [**`squash_merge_commit_title`**](#var-squash_merge_commit_title): *(Optional `string`)*
+
+ Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
+
+ Default is `"COMMIT_OR_PR_TITLE"`.
+
+- [**`squash_merge_commit_message`**](#var-squash_merge_commit_message): *(Optional `string`)*
+
+ Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
+
+ Default is `"COMMIT_MESSAGES"`.
+
+- [**`merge_commit_title`**](#var-merge_commit_title): *(Optional `string`)*
+
+ Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
+
+ Default is `"MERGE_MESSAGE"`.
+
+- [**`merge_commit_message`**](#var-merge_commit_message): *(Optional `string`)*
+
+ Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
+
+ Default is `"PR_TITLE"`.
+
- [**`description`**](#var-description): *(Optional `string`)*
A description of the repository.
@@ -310,6 +345,10 @@ See [variables.tf] and [examples/] for details and use-cases.
Set to `false` to disable security alerts for vulnerable dependencies.
Enabling requires alerts to be enabled on the owner level.
+- [**`ignore_vulnerability_alerts_during_read`**](#var-ignore_vulnerability_alerts_during_read): *(Optional `bool`)*
+
+ Set to `true` to not call the vulnerability alerts endpoint so the resource can also be used without admin permissions during read.
+
- [**`archive_on_destroy`**](#var-archive_on_destroy): *(Optional `bool`)*
Set to `false` to not archive the repository instead of deleting on destroy.
diff --git a/README.tfdoc.hcl b/README.tfdoc.hcl
index ab43b59..977a231 100644
--- a/README.tfdoc.hcl
+++ b/README.tfdoc.hcl
@@ -21,7 +21,7 @@ header {
}
badge "tf-gh" {
- image = "https://img.shields.io/badge/GH-4.10+-F8991D.svg?logo=terraform"
+ image = "https://img.shields.io/badge/GH-4.31+-F8991D.svg?logo=terraform"
url = "https://github.com/terraform-providers/terraform-provider-github/releases"
text = "Github Provider Version"
}
@@ -39,11 +39,11 @@ section {
content = <<-END
A [Terraform] module for creating a public or private repository on [Github].
- **_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.20 and above from `integrations/github`._**
+ **_This module supports Terraform v1.x and is compatible with the Official Terraform GitHub Provider v4.31 and above from `integrations/github`._**
**Attention: This module is incompatible with the Hashicorp GitHub Provider! The latest version of this module supporting `hashicorp/github` provider is `~> 0.10.0`**
- ** Note: Versions 5.3.0, 5.4.0, and 5.5.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
+ ** Note: Versions 5.3.0, 5.4.0, 5.5.0, and 5.6.0 of the Terraform Github Provider have broken branch protections support and should not be used.**
END
section {
@@ -92,7 +92,8 @@ section {
Teams,
Deploy Keys,
Projects,
- Repository Webhooks
+ Repository Webhooks,
+ GitHub App Installations
- _Features not yet implemented_:
Project Columns support,
@@ -109,7 +110,7 @@ section {
```hcl
module "repository" {
source = "mineiros-io/repository/github"
- version = "~> 0.16.0"
+ version = "~> 0.18.0"
name = "terraform-github-repository"
license_template = "apache-2.0"
@@ -164,18 +165,28 @@ section {
`has_issues`,
`has_projects`,
`has_wiki`,
+ `has_downloads`,
+ `delete_branch_on_merge`,
+ `is_template`,
`allow_merge_commit`,
`allow_rebase_merge`,
`allow_squash_merge`,
`allow_auto_merge`,
- `has_downloads`,
`auto_init`,
`gitignore_template`,
`license_template`,
+ `squash_merge_commit_title`,
+ `squash_merge_commit_message`,
+ `merge_commit_title`,
+ `merge_commit_message`,
+ `auto_init`,
`default_branch`,
`topics`,
`issue_labels_create`,
- `issue_labels_merge_with_github_labels`.
+ `issue_labels_merge_with_github_labels`,
+ `vulnerability_alerts`,
+ `ignore_vulnerability_alerts_during_read`,
+ `template`.
Module defaults are used for all arguments that are not set in `defaults`.
Using top level arguments override defaults set by this argument.
@@ -251,6 +262,38 @@ section {
END
}
+ variable "squash_merge_commit_title" {
+ type = string
+ default = "COMMIT_OR_PR_TITLE"
+ description = <<-END
+ Set to `PR_TITLE` or `COMMIT_OR_PR_TITLE` for a default squash merge commit title.
+ END
+ }
+
+ variable "squash_merge_commit_message" {
+ type = string
+ default = "COMMIT_MESSAGES"
+ description = <<-END
+ Set to `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message.
+ END
+ }
+
+ variable "merge_commit_title" {
+ type = string
+ default = "MERGE_MESSAGE"
+ description = <<-END
+ Set to `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title.
+ END
+ }
+
+ variable "merge_commit_message" {
+ type = string
+ default = "PR_TITLE"
+ description = <<-END
+ Set to `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message.
+ END
+ }
+
variable "description" {
type = string
default = ""
@@ -377,6 +420,13 @@ section {
END
}
+ variable "ignore_vulnerability_alerts_during_read" {
+ type = bool
+ description = <<-END
+ Set to `true` to not call the vulnerability alerts endpoint so the resource can also be used without admin permissions during read.
+ END
+ }
+
variable "archive_on_destroy" {
type = bool
default = true
diff --git a/examples/public-repository/README.md b/examples/public-repository/README.md
index 6014f5a..564a373 100644
--- a/examples/public-repository/README.md
+++ b/examples/public-repository/README.md
@@ -15,7 +15,7 @@ branch protection.
```hcl
module "repository" {
source = "mineiros-io/repository/github"
- version = "~> 0.13.0"
+ version = "~> 0.18.0"
module_depends_on = [
github_team.team
diff --git a/main.tf b/main.tf
index 547e0e7..6e3d7d2 100644
--- a/main.tf
+++ b/main.tf
@@ -11,6 +11,7 @@ locals {
visibility = var.visibility == null ? lookup(var.defaults, "visibility", local.private_visibility) : var.visibility
has_issues = var.has_issues == null ? lookup(var.defaults, "has_issues", false) : var.has_issues
has_projects = var.has_projects == null ? lookup(var.defaults, "has_projects", false) : length(var.projects) > 0 ? true : var.has_projects
+ has_downloads = var.has_downloads == null ? lookup(var.defaults, "has_downloads", false) : var.has_downloads
has_wiki = var.has_wiki == null ? lookup(var.defaults, "has_wiki", false) : var.has_wiki
allow_merge_commit = var.allow_merge_commit == null ? lookup(var.defaults, "allow_merge_commit", true) : var.allow_merge_commit
allow_rebase_merge = var.allow_rebase_merge == null ? lookup(var.defaults, "allow_rebase_merge", false) : var.allow_rebase_merge
@@ -18,7 +19,6 @@ locals {
allow_auto_merge = var.allow_auto_merge == null ? lookup(var.defaults, "allow_auto_merge", false) : var.allow_auto_merge
delete_branch_on_merge = var.delete_branch_on_merge == null ? lookup(var.defaults, "delete_branch_on_merge", true) : var.delete_branch_on_merge
is_template = var.is_template == null ? lookup(var.defaults, "is_template", false) : var.is_template
- has_downloads = var.has_downloads == null ? lookup(var.defaults, "has_downloads", false) : var.has_downloads
auto_init = var.auto_init == null ? lookup(var.defaults, "auto_init", true) : var.auto_init
gitignore_template = var.gitignore_template == null ? lookup(var.defaults, "gitignore_template", "") : var.gitignore_template
license_template = var.license_template == null ? lookup(var.defaults, "license_template", "") : var.license_template
@@ -29,6 +29,11 @@ locals {
issue_labels_create = var.issue_labels_create == null ? lookup(var.defaults, "issue_labels_create", local.issue_labels_create_computed) : var.issue_labels_create
branch_protections_v3 = var.branch_protections_v3 == null ? var.branch_protections : var.branch_protections_v3
+ squash_merge_commit_title = var.squash_merge_commit_title == null ? try(var.defaults.squash_merge_commit_title, "COMMIT_OR_PR_TITLE") : var.squash_merge_commit_title
+ squash_merge_commit_message = var.squash_merge_commit_message == null ? try(var.defaults.squash_merge_commit_message, "COMMIT_MESSAGES") : var.squash_merge_commit_message
+ merge_commit_title = var.merge_commit_title == null ? try(var.defaults.merge_commit_title, "MERGE_MESSAGE") : var.merge_commit_title
+ merge_commit_message = var.merge_commit_message == null ? try(var.merge_commit_message, "PR_TITLE") : var.merge_commit_message
+
issue_labels_create_computed = local.has_issues || length(var.issue_labels) > 0
# for readability
@@ -37,7 +42,8 @@ locals {
issue_labels_merge_with_github_labels = local.gh_labels
# Per default, GitHub activates vulnerability alerts for public repositories and disables it for private repositories
- vulnerability_alerts = var.vulnerability_alerts != null ? var.vulnerability_alerts : local.private ? false : true
+ vulnerability_alerts = var.vulnerability_alerts != null ? var.vulnerability_alerts : local.private ? false : true
+ ignore_vulnerability_alerts_during_read = var.ignore_vulnerability_alerts_during_read == null ? try(var.defaults.ignore_vulnerability_alerts_during_read, null) : var.ignore_vulnerability_alerts_during_read
}
locals {
@@ -113,6 +119,11 @@ resource "github_repository" "repository" {
archive_on_destroy = var.archive_on_destroy
vulnerability_alerts = local.vulnerability_alerts
+ squash_merge_commit_title = local.squash_merge_commit_title
+ squash_merge_commit_message = local.squash_merge_commit_message
+ merge_commit_title = local.merge_commit_title
+ merge_commit_message = local.merge_commit_message
+
dynamic "template" {
for_each = local.template
diff --git a/test/unit-complete/provider.tf b/test/unit-complete/provider.tf
index 7cd89ca..7536a17 100644
--- a/test/unit-complete/provider.tf
+++ b/test/unit-complete/provider.tf
@@ -6,7 +6,7 @@ terraform {
required_providers {
github = {
source = "integrations/github"
- version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0"
+ version = "~> 5.0, !=5.3.0, !=5.4.0, !=5.5.0, !=5.6.0, !=5.7.0"
}
tls = {
source = "hashicorp/tls"
diff --git a/test/unit-complete/variables.tf b/test/unit-complete/variables.tf
index 55b155f..7ba82eb 100644
--- a/test/unit-complete/variables.tf
+++ b/test/unit-complete/variables.tf
@@ -70,7 +70,6 @@ variable "allow_auto_merge" {
default = true
}
-
variable "has_downloads" {
description = "Set to true to enable the (deprecated) downloads features on the repository."
type = bool
@@ -156,6 +155,7 @@ variable "repository_defaults" {
homepage_url = "https://github.com/mineiros-io"
visibility = "private"
allow_merge_commit = true
+ allow_squash_merge = false
gitignore_template = "Terraform"
license_template = "mit"
topics = ["terraform", "integration-test"]
diff --git a/variables.tf b/variables.tf
index 3eac082..88ac6fd 100644
--- a/variables.tf
+++ b/variables.tf
@@ -30,22 +30,33 @@ variable "defaults" {
# Example:
# defaults = {
- # homepage_url = "https://mineiros.io/"
- # visibility = "private"
- # has_issues = false
- # has_projects = false
- # has_wiki = false
- # delete_branch_on_merge = true
- # allow_merge_commit = true
- # allow_rebase_merge = false
- # allow_squash_merge = false
- # allow_auto_merge = false
- # has_downloads = false
- # auto_init = true
- # gitignore_template = "terraform"
- # license_template = "mit"
- # default_branch = "main"
- # topics = ["topic-1", "topic-2"]
+ # homepage_url = "https://mineiros.io/"
+ # visibility = "private"
+ # has_issues = false
+ # has_projects = false
+ # has_wiki = false
+ # has_downloads = false
+ # delete_branch_on_merge = true
+ # is_template = true
+ # allow_merge_commit = true
+ # allow_rebase_merge = false
+ # allow_squash_merge = false
+ # allow_auto_merge = false
+ # auto_init = true
+ # gitignore_template = "terraform"
+ # license_template = "mit"
+ # default_branch = "main"
+ # topics = ["topic-1", "topic-2"]
+ # template = "terraform-module-template"
+ # vulnerability_alerts = true
+ # ignore_vulnerability_alerts_during_read = true
+ # issue_labels_create = false
+ # squash_merge_commit_title = "PR_TITLE"
+ # squash_merge_commit_message = "COMMIT_MESSAGES"
+ # merge_commit_title = "PR_TITLE"
+ # merge_commit_message = "PR_BODY"
+ # vulnerability_alerts = true
+ # ignore_vulnerability_alerts_during_read = true
# }
default = {}
@@ -522,6 +533,12 @@ variable "vulnerability_alerts" {
default = null
}
+variable "ignore_vulnerability_alerts_during_read" {
+ type = bool
+ description = "(Optional) Set to `true` to not call the vulnerability alerts endpoint so the resource can also be used without admin permissions during read."
+ default = null
+}
+
variable "archive_on_destroy" {
type = string
description = "(Optional) Set to `false` to not archive the repository instead of deleting on destroy."
@@ -534,6 +551,30 @@ variable "app_installations" {
default = []
}
+variable "squash_merge_commit_title" {
+ type = string
+ description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
+ default = "COMMIT_OR_PR_TITLE"
+}
+
+variable "squash_merge_commit_message" {
+ type = string
+ description = "(Optional) Can be `PR_BODY`, `COMMIT_MESSAGES`, or `BLANK` for a default squash merge commit message."
+ default = "COMMIT_MESSAGES"
+}
+
+variable "merge_commit_title" {
+ type = string
+ description = "(Optional) Can be `PR_TITLE` or `MERGE_MESSAGE` for a default merge commit title."
+ default = "MERGE_MESSAGE"
+}
+
+variable "merge_commit_message" {
+ type = string
+ description = "(Optional) Can be `PR_BODY`, `PR_TITLE`, or `BLANK` for a default merge commit message."
+ default = "PR_TITLE"
+}
+
# ------------------------------------------------------------------------------
# MODULE CONFIGURATION PARAMETERS
# These variables are used to configure the module.
diff --git a/versions.tf b/versions.tf
index 01e52ac..5819c2c 100644
--- a/versions.tf
+++ b/versions.tf
@@ -9,7 +9,7 @@ terraform {
required_providers {
github = {
source = "integrations/github"
- version = ">= 4.20, < 6.0"
+ version = ">= 4.31, < 6.0"
}
}
}