Skip to content

Commit

Permalink
fix: default repository branch warning
Browse files Browse the repository at this point in the history
  • Loading branch information
bounteous17 committed Feb 19, 2024
1 parent 1e2daea commit a40fd1a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 28 deletions.
31 changes: 9 additions & 22 deletions repositories/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,14 @@ module "xk6-mongo" {
source = "./templates"

github_repository = {
name = "xk6-mongo"
visibility = "public"
name = "xk6-mongo"
default_branch = "master"
visibility = "public"
}

github_repository_topics = ["load-testing", "golang", "mongo", "atlas"]
}

module "actions" {
source = "./templates"

github_repository = {
name = "actions"
description = "A collection of GitHub actions to use in our organization"
visibility = "public"
}

github_teams_repository = [{
team_id = var.teams-name.team-actions
permission = "maintain"
}]

github_repository_topics = ["github", "automations", "pipeline"]
}

module "morning-slackbot" {
source = "./templates"

Expand All @@ -63,9 +47,10 @@ module "rascal" {
source = "./templates"

github_repository = {
name = "rascal"
description = "A config driven wrapper for amqp.node supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption and channel pooling."
visibility = "public"
name = "rascal"
default_branch = "master"
description = "A config driven wrapper for amqp.node supporting multi-host connections, automatic error recovery, redelivery flood protection, transparent encryption / decryption and channel pooling."
visibility = "public"
pages = {
source = {
branch = "master"
Expand All @@ -75,6 +60,7 @@ module "rascal" {
}

github_branch_protection = {
pull_request_bypassers = ["/cressie176"]
required_pull_request_reviews = {
required_approving_review_count = 1
}
Expand Down Expand Up @@ -138,6 +124,7 @@ module "systemic" {

github_repository = {
name = "systemic"
default_branch = "master"
description = "📦 A minimal dependency injection framework."
visibility = "public"
homepage_url = "https://onebeyond.github.io/systemic"
Expand Down
11 changes: 8 additions & 3 deletions repositories/templates/github_branch_protection.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ locals {
var.github_branch_protection_defaults.required_pull_request_reviews,
var.github_branch_protection.required_pull_request_reviews
)
},
{
pull_request_bypassers = setunion(
var.github_branch_protection_defaults.pull_request_bypassers,
var.github_branch_protection.pull_request_bypassers
)
}
)
}
Expand All @@ -15,7 +21,7 @@ resource "github_branch_protection" "main" {
depends_on = [github_repository.repo]
repository_id = github_repository.repo.node_id

pattern = github_repository.repo.default_branch
pattern = local.github_repository.default_branch
enforce_admins = local.github_branch_protection.enforce_admins
allows_deletions = local.github_branch_protection.allows_deletions
allows_force_pushes = local.github_branch_protection.allows_force_pushes
Expand All @@ -31,7 +37,6 @@ resource "github_branch_protection" "main" {
restrict_dismissals = local.github_branch_protection.required_pull_request_reviews.restrict_dismissals
required_approving_review_count = local.github_branch_protection.required_pull_request_reviews.required_approving_review_count
require_last_push_approval = local.github_branch_protection.required_pull_request_reviews.require_last_push_approval
pull_request_bypassers = ["/Bounteous17"]

pull_request_bypassers = local.github_branch_protection.pull_request_bypassers
}
}
2 changes: 1 addition & 1 deletion repositories/templates/github_repository.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
locals {
github_repository = merge(
var.github_repository_defaults,
var.github_repository
var.github_repository,
)
}

Expand Down
9 changes: 7 additions & 2 deletions repositories/templates/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
variable "github_repository_defaults" {
type = object({
name = optional(string),
default_branch = string,
description = string
archive_on_destroy = bool,
allow_auto_merge = bool,
Expand All @@ -21,7 +22,6 @@ variable "github_repository_defaults" {
is_template = bool,
vulnerability_alerts = bool,
visibility = string,
pattern = string,
enforce_admins = bool,
allows_deletions = bool,
allows_force_pushes = bool,
Expand All @@ -33,6 +33,7 @@ variable "github_repository_defaults" {
})

default = {
default_branch = "main",
archive_on_destroy = true,
description = ""
allow_auto_merge = false,
Expand All @@ -51,7 +52,6 @@ variable "github_repository_defaults" {
is_template = false,
vulnerability_alerts = false,
visibility = "public",
pattern = "main",
enforce_admins = true,
allows_deletions = false,
allows_force_pushes = false,
Expand Down Expand Up @@ -79,6 +79,7 @@ variable "github_branch_protection_defaults" {
require_signed_commits = bool,
require_conversation_resolution = bool,
required_pull_request_reviews = map(string)
pull_request_bypassers = set(string)
})

default = {
Expand All @@ -93,16 +94,20 @@ variable "github_branch_protection_defaults" {
required_approving_review_count = 2
require_last_push_approval = true
}
pull_request_bypassers = ["/Bounteous17"]
}
}

variable "github_branch_protection" {
type = object({
required_pull_request_reviews = optional(map(string), {})
pull_request_bypassers = optional(set(string), [])
})

default = {
default_branch = "main"
required_pull_request_reviews = {}
pull_request_bypassers = []
}
}

Expand Down

0 comments on commit a40fd1a

Please sign in to comment.