Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added optional configuration to keep squash merges tidy #8700

Merged
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
40 changes: 21 additions & 19 deletions terraform/github/modules/repository/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,27 @@ locals {

# Repository basics
resource "github_repository" "default" {
name = var.name
description = join(" • ", [var.description, "This repository is defined and managed in Terraform"])
allow_merge_commit = true
allow_squash_merge = true
allow_rebase_merge = true
allow_update_branch = true
archived = false
archive_on_destroy = true
auto_init = false
delete_branch_on_merge = true
has_issues = true
has_projects = true
has_wiki = var.type == "core" ? true : false
has_downloads = true
homepage_url = var.homepage_url
is_template = var.type == "template" ? true : false
topics = concat(local.topics, var.topics)
visibility = var.visibility
vulnerability_alerts = true
name = var.name
description = join(" • ", [var.description, "This repository is defined and managed in Terraform"])
allow_merge_commit = true
allow_squash_merge = true
allow_rebase_merge = true
allow_update_branch = true
archived = false
archive_on_destroy = true
auto_init = false
delete_branch_on_merge = true
has_issues = true
has_projects = true
has_wiki = var.type == "core" ? true : false
has_downloads = true
homepage_url = var.homepage_url
is_template = var.type == "template" ? true : false
squash_merge_commit_title = var.squash_merge_commit_message == true ? "PR_TITLE" : null
squash_merge_commit_message = var.squash_merge_commit_title == true ? "COMMIT_MESSAGES" : null
topics = concat(local.topics, var.topics)
visibility = var.visibility
vulnerability_alerts = true

security_and_analysis {
dynamic "advanced_security" {
Expand Down
48 changes: 30 additions & 18 deletions terraform/github/modules/repository/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,48 @@ variable "description" {
description = "Repository description"
}

variable "dismissal_restrictions" {
type = list(string)
description = "The list of actor Names/IDs with dismissal access e.g. 'exampleorganization/exampleteam' or '/exampleuser'"
default = []
}

variable "homepage_url" {
type = string
description = "Repository homepage URL"
default = ""
}

variable "required_checks" {
type = list(string)
description = "List of required checks"
default = []
}

variable "restrict_dismissals" {
type = bool
description = "Restrict pull request review dismissals"
default = false
}

variable "secrets" {
type = map(any)
description = "key:value map for GitHub actions secrets"
default = {}
}

variable "squash_merge_commit_message" {
type = bool
description = "Should squash merge commit message be set to MERGE_MESSAGE?"
default = true
}

variable "squash_merge_commit_title" {
type = bool
description = "Should squash merge commit title be set to PR_TITLE?"
default = true
}

variable "topics" {
type = list(string)
description = "Repository topics, in addition to 'modernisation-platform', 'terraform-module', 'civil-service'"
Expand All @@ -36,21 +66,3 @@ variable "visibility" {
description = "Visibility type: `public`, `internal`, `private`"
default = "public"
}

variable "required_checks" {
type = list(string)
description = "List of required checks"
default = []
}

variable "restrict_dismissals" {
type = bool
description = "Restrict pull request review dismissals"
default = false
}

variable "dismissal_restrictions" {
type = list(string)
description = "The list of actor Names/IDs with dismissal access e.g. 'exampleorganization/exampleteam' or '/exampleuser'"
default = []
}
10 changes: 6 additions & 4 deletions terraform/github/repositories.tf
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,12 @@ module "terraform-module-cross-account-access" {
}

module "terraform-module-environments" {
source = "./modules/repository"
name = "modernisation-platform-terraform-environments"
type = "module"
description = "Module for creating organizational units and accounts within AWS Organizations from JSON files"
source = "./modules/repository"
name = "modernisation-platform-terraform-environments"
type = "module"
description = "Module for creating organizational units and accounts within AWS Organizations from JSON files"
squash_merge_commit_message = false
squash_merge_commit_title = false
topics = [
"organizational-units",
"aws"
Expand Down
Loading