Skip to content

About

Terraform modules to manage GitHub repository resources

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

 
 

Repository files navigation

GitHub Repository Terraform Module

Terraform module to manage GitHub repository resources.

Usage

module "repository" {
  source  = "Tensho/repository/github"
  version = "~> 1.4"

  name        = "example"
  description = "Example repository managed by Terraform"
  visibility  = "public"

  allow_merge_commit     = false
  allow_squash_merge     = true
  allow_rebase_merge     = true
  delete_branch_on_merge = true
}

module "rulesets" {
  source  = "Tensho/repository/github//modules/rulesets"
  version = "~> 1.0"

  repository = module.repository.name

  rulesets = {
    "default-branch" = {
      name = "Default Branch"

      conditions = {
        ref_name = {
          include = ["~DEFAULT_BRANCH"]
        }
      }

      rules = {
        deletion         = true
        non_fast_forward = true

        pull_request = {
          required_approving_review_count = 1
        }
      }
    }
  }
}

Check out comprehensive examples in examples folder.

Features

Note

This module covers repository-scoped resources only. Organisation-scoped resources live in terraform-github-organisation.

Contributing

See CONTRIBUTING.md for development setup and testing instructions.

Requirements

Name Version
terraform >= 1.7.0
github ~> 6.13

Providers

Name Version
github ~> 6.13

Modules

No modules.

Resources

Name Type
github_repository.default resource

Inputs

Name Description Type Default Required
allow_auto_merge Allow auto-merging pull requests. bool null no
allow_forking Allow private forking. Applies only to private and internal repositories. bool null no
allow_merge_commit Allow merge commits. bool null no
allow_rebase_merge Allow rebase merges. bool null no
allow_squash_merge Allow squash merges. bool null no
allow_update_branch Always suggest updating pull request branches. bool null no
archive_on_destroy Archive the repository instead of deleting it on destroy. bool true no
archived Archive the repository. Archived repositories are read-only. bool null no
delete_branch_on_merge Delete head branch after a pull request is merged. bool null no
description Repository description. string null no
has_discussions Enable GitHub Discussions. bool null no
has_issues Enable GitHub Issues. bool null no
has_projects Enable GitHub Projects. bool null no
has_wiki Enable GitHub Wiki. bool null no
homepage_url URL of a page describing the repository. string null no
is_template Mark the repository as a template. bool null no
merge_commit_message Default merge commit message: PR_BODY, PR_TITLE or BLANK. string null no
merge_commit_title Default merge commit title: PR_TITLE or MERGE_MESSAGE. string null no
name Repository name. string n/a yes
security_and_analysis Security and analysis feature statuses: enabled or disabled. Omitted features keep their current status.
object({
advanced_security = optional(string)
code_security = optional(string)
secret_scanning = optional(string)
secret_scanning_ai_detection = optional(string)
secret_scanning_non_provider_patterns = optional(string)
secret_scanning_push_protection = optional(string)
})
null no
squash_merge_commit_message Default squash merge commit message: PR_BODY, COMMIT_MESSAGES or BLANK. string null no
squash_merge_commit_title Default squash merge commit title: PR_TITLE or COMMIT_OR_PR_TITLE. string null no
topics Repository topics. set(string) null no
visibility Repository visibility: public, private or internal. string "private" no
web_commit_signoff_required Require contributors to sign off on web-based commits. bool null no

Outputs

Name Description
full_name Repository full name (owner/name).
name Repository name.
node_id Repository GraphQL node ID.
repo_id Repository ID.

About

Terraform modules to manage GitHub repository resources

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages