Skip to content

Commit

Permalink
update root module
Browse files Browse the repository at this point in the history
  • Loading branch information
kevcube committed Sep 6, 2024
1 parent 138e2d5 commit 91b0d63
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 77 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ No providers.
| Name | Source | Version |
|------|--------|---------|
| actions_runner_group | ./modules/actions_runner_group | n/a |
| organization_block | ./modules/organization_block | n/a |
| organization_ruleset | ./modules/organization_ruleset | n/a |
| organization_secret | ./modules/actions_organization_secret | n/a |
| organization_settings | ./modules/organization_settings | n/a |
| organization_variable | ./modules/actions_organization_variable | n/a |

## Resources

Expand All @@ -36,9 +40,11 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| actions_runner_groups | A map of actions runner groups to create in your GitHub organization. Map key is the name of the runner group. | ```map(object({ restricted_to_workflows = optional(list(string)) selected_repository_ids = optional(list(string)) selected_workflows = optional(list(string)) visibility = optional(string) allows_public_repositories = optional(bool) }))``` | `{}` | no |
| advanced_security_enabled_for_new_repositories | Whether or not advanced security is enabled for new repositories. Defaults to false. | `bool` | `null` | no |
| allows_public_repositories | Whether public repositories can be added to the runner group | `bool` | `null` | no |
| billing_email | The billing email address for the organization. | `string` | n/a | yes |
| blocked_usernames | A list of usernames to block from your GitHub organization. | `list(string)` | `[]` | no |
| blog | The blog URL for the organization. | `string` | `null` | no |
| company | The company name for the organization. | `string` | `null` | no |
| default_repository_permission | The default permission for organization members to create new repositories. Can be one of read, write, admin, or none. Defaults to read. | `string` | `null` | no |
Expand All @@ -59,6 +65,9 @@ No resources.
| members_can_create_repositories | Whether or not organization members can create new repositories. Defaults to true. | `bool` | `null` | no |
| members_can_fork_private_repositories | Whether or not organization members can fork private repositories. Defaults to false. | `bool` | `null` | no |
| organization_name | The name for the organization. | `string` | `null` | no |
| organization_rulesets | A map of organization rulesets to create. The map key is the name of the ruleset. | ```map(object({ enforcement = string rules = list(object({ # Enterprise only! Use `conditions` block for matching branches. branch_name_pattern = optional(list(object({ operator = string pattern = string name = optional(string) negate = optional(bool) })), []) # Enterprise only! commit_author_email_pattern = optional(list(object({ operator = string pattern = string name = optional(string) negate = optional(bool) })), []) # Enterprise only! commit_message_pattern = optional(list(object({ operator = string pattern = string name = optional(string) negate = optional(bool) })), []) # Enterprise only! committer_email_pattern = optional(list(object({ operator = string pattern = string name = optional(string) negate = optional(bool) })), []) creation = optional(bool) deletion = optional(bool) non_fast_forward = optional(bool) pull_request = optional(list(object({ dismiss_stale_reviews_on_push = optional(bool) require_code_owner_review = optional(bool) require_last_push_approval = optional(bool) required_approving_review_count = optional(number) required_review_thread_resolution = optional(bool) })), []) required_linear_history = optional(bool) required_signatures = optional(bool) required_status_checks = optional(list(object({ required_check = list(object({ context = string integration_id = optional(number) })) strict_required_status_checks_policy = optional(bool) })), []) required_workflows = optional(list(object({ required_workflow = list(object({ repository_id = number path = string ref = optional(string) })) })), []) tag_name_pattern = optional(list(object({ operator = string pattern = string name = optional(string) negate = optional(bool) })), []) update = optional(bool) })) target = string bypass_actors = optional(list(object({ actor_id = number actor_type = string bypass_mode = optional(string) })), []) }))``` | n/a | yes |
| organization_secrets | A map of organization secrets to create. The map key is the secret name. | ```map(object({ encrypted_value = optional(string) plaintext_value = optional(string) visibility = string selected_repository_ids = optional(list(string)) }))``` | `{}` | no |
| organization_variables | n/a | ```map(object({ value = string visibility = string selected_repository_ids = optional(list(string)) }))``` | n/a | yes |
| restricted_to_workflows | If true, the runner group will be restricted to running only the workflows specified in the selected_workflows array. Defaults to false. | `bool` | `null` | no |
| runner_group_name | Name of the runner group | `string` | n/a | yes |
| secret_scanning_enabled_for_new_repositories | Whether or not secret scanning is enabled for new repositories. Defaults to false. | `bool` | `null` | no |
Expand Down
95 changes: 18 additions & 77 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,87 +49,18 @@ module "organization_block" {
}

module "organization_ruleset" {
source = "./modules/organization_ruleset"

for_each = var.organization_rulesets
}

variable "organization_rulesets" {
description = "A map of organization rulesets to create. The map key is the name of the ruleset."
type = map(object({
enforcement = string
rules = list(object({
# Enterprise only! Use `conditions` block for matching branches.
branch_name_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
commit_author_email_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
commit_message_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
committer_email_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
creation = optional(bool)
deletion = optional(bool)
non_fast_forward = optional(bool)
pull_request = optional(list(object({
dismiss_stale_reviews_on_push = optional(bool)
require_code_owner_review = optional(bool)
require_last_push_approval = optional(bool)
required_approving_review_count = optional(number)
required_review_thread_resolution = optional(bool)
})), [])
required_linear_history = optional(bool)
required_signatures = optional(bool)
required_status_checks = optional(list(object({
required_check = list(object({
context = string
integration_id = optional(number)
}))
strict_required_status_checks_policy = optional(bool)
})), [])
required_workflows = optional(list(object({
required_workflow = list(object({
repository_id = number
path = string
ref = optional(string)
}))
})), [])
tag_name_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
update = optional(bool)
}))
target = string
bypass_actors = optional(list(object({
actor_id = number
actor_type = string
bypass_mode = optional(string)
})), [])
}))
name = each.key
enforcement = each.value.enforcement
rules = each.value.rules
target = each.value.target
bypass_actors = each.value.bypass_actors
}

module "organization_secret" {
source = "./modules/actions_organization_secrets"
source = "./modules/actions_organization_secret"
for_each = var.organization_secrets

secret_name = each.key
Expand All @@ -138,3 +69,13 @@ module "organization_secret" {
visibility = each.value.visibility
selected_repository_ids = each.value.selected_repository_ids
}

module "organization_variable" {
source = "./modules/actions_organization_variable"
for_each = var.organization_variables

variable_name = each.key
value = each.value.value
visibility = each.value.visibility
selected_repository_ids = each.value.selected_repository_ids
}
92 changes: 92 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,18 @@ variable "actions_runner_groups" {
default = {}
}

##################################
# Organization actions variables #
##################################

variable "organization_variables" {
type = map(object({
value = string
visibility = string
selected_repository_ids = optional(list(string))
}))
}

################################
# Organization actions secrets #
################################
Expand All @@ -239,3 +251,83 @@ variable "organization_secrets" {
}))
default = {}
}

#########################
# Organization rulesets #
#########################

variable "organization_rulesets" {
description = "A map of organization rulesets to create. The map key is the name of the ruleset."
type = map(object({
enforcement = string
rules = list(object({
# Enterprise only! Use `conditions` block for matching branches.
branch_name_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
commit_author_email_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
commit_message_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
# Enterprise only!
committer_email_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
creation = optional(bool)
deletion = optional(bool)
non_fast_forward = optional(bool)
pull_request = optional(list(object({
dismiss_stale_reviews_on_push = optional(bool)
require_code_owner_review = optional(bool)
require_last_push_approval = optional(bool)
required_approving_review_count = optional(number)
required_review_thread_resolution = optional(bool)
})), [])
required_linear_history = optional(bool)
required_signatures = optional(bool)
required_status_checks = optional(list(object({
required_check = list(object({
context = string
integration_id = optional(number)
}))
strict_required_status_checks_policy = optional(bool)
})), [])
required_workflows = optional(list(object({
required_workflow = list(object({
repository_id = number
path = string
ref = optional(string)
}))
})), [])
tag_name_pattern = optional(list(object({
operator = string
pattern = string
name = optional(string)
negate = optional(bool)
})), [])
update = optional(bool)
}))
target = string
bypass_actors = optional(list(object({
actor_id = number
actor_type = string
bypass_mode = optional(string)
})), [])
}))
}

0 comments on commit 91b0d63

Please sign in to comment.