Terraform module to create Github Environments for Github Actions.
Note: Github Actions Environments are available for Public Repositories and Github Enterprise Cloud users. (doc)
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
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
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
.
Report issues/questions/feature requests on in the issues section.
Full contributing guidelines are covered here.
Name | Version |
---|---|
github | ~> 4.0 |
Name | Version |
---|---|
github | ~> 4.0 |
No modules.
Name | Type |
---|---|
github_repository_environment.this | resource |
github_repository.this | data source |
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 |
Name | Description |
---|---|
environments | A map of the created environments |
repository | The target github repository informations |