Skip to content

Latest commit

 

History

History
125 lines (87 loc) · 4.08 KB

README.md

File metadata and controls

125 lines (87 loc) · 4.08 KB

terraform-github-environments

semantic-release terraform-github-environments

Terraform module to create Github Environments for Github Actions.

Usage

Note: Github Actions Environments are available for Public Repositories and Github Enterprise Cloud users. (doc)

Github Authentication

You will need to authenticate against Github using an OAuth Token or Personal Access Token. See Github Provider#Authentication for more informations.

This can be done by setting the token argument of the github provider or by exporting your Token to the GITHUB_TOKEN environment variable.

Provider configuration:

provider "github" {
  token = var.token # or `GITHUB_TOKEN`
}

Environment variable configuration:

export GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Creating the Environments

This module takes a map of objects for each Environement to configure.

module "env" {
  source = "../"

  repository = "tbobm/terraform-github-secrets"

  environments = {
    "stable" = {}

    "protected" = {
      deployment_branch_policy = {
        protected_branches     = true
        custom_branch_policies = false
      }
    }
  }
}

Here we defined two environemnts:

  • the stable environment
  • the protected environment with protected branches enabled

Doc generation

Code formatting and documentation for variables and outputs is generated using pre-commit-terraform hooks which uses terraform-docs.

Follow these instructions to install pre-commit locally.

And install terraform-docs with go get github.com/segmentio/terraform-docs or brew install terraform-docs.

Contributing

Report issues/questions/feature requests on in the issues section.

Full contributing guidelines are covered here.

Requirements

Name Version
github ~> 4.0

Providers

Name Version
github ~> 4.0

Modules

No modules.

Resources

Name Type
github_repository_environment.this resource
github_repository.this data source

Inputs

Name Description Type Default Required
environments A map of environment definitions map(any) n/a yes
repository The full name of the repository in the form org/repo string n/a yes

Outputs

Name Description
environments A map of the created environments
repository The target github repository informations