github_organization_ruleset (Resource)

Creates a GitHub organization ruleset.

This resource allows you to create and manage rulesets on the organization level. When applied, a new ruleset will be created. When destroyed, that ruleset will be removed.

Example Usage

resource "github_organization_ruleset" "example" {
  name        = "example"
  target      = "branch"
  enforcement = "active"

  conditions {
    ref_name {
      include = ["~ALL"]
      exclude = []
    }
  }

  bypass_actors {
    actor_id    = 13473
    actor_type  = "Integration"
    bypass_mode = "always"
  }

  rules {
    creation                = true
    update                  = true
    deletion                = true
    required_linear_history = true
    required_signatures     = true

    branch_name_pattern {
      name     = "example"
      negate   = false
      operator = "starts_with"
      pattern  = "ex"
    }
  }
}

Argument Reference

Rules

The rules block supports the following:

rules.branch_name_pattern

rules.commit_author_email_pattern

rules.commit_message_pattern

rules.committer_email_pattern

rules.pull_request

rules.required_status_checks

required_status_checks.required_check

rules.required_workflows

rules.required_workflows.required_workflow

rules.tag_name_pattern

bypass_actors

~>Note: at the time of writing this, the following actor types correspond to the following actor IDs:

conditions

One of repository_id and repository_name must be set for the rule to target any repositories.

conditions.ref_name

conditions.repository_name

Attributes Reference

The following additional attributes are exported:

Import

GitHub Organization Rulesets can be imported using the GitHub ruleset ID e.g.

$ terraform import github_organization_ruleset.example 12345