GitHub repository module which manages configuration and life-cycle of all your GitHub repository configuration.
To manage the GitHub resources, provide a token from an account or a GitHub App with appropriate permissions. It should have:
- Read access to
metadata
- Read and write access to
administration
,code
, andsecrets
The GitHub provider requires a GitHub token or GitHub App installation in order to manage resources.
There are several ways to provide the required token:
- Set the
token
argument in the provider configuration. You can set thetoken
argument in the provider configuration. Use an input variable for the token. - Set the
GITHUB_TOKEN
environment variable. The provider can read theGITHUB_TOKEN
environment variable and the token stored there to authenticate.
There are several ways to provide the required GitHub App installation:
- Set the
app_auth
argument in the provider configuration. You can set the app_auth argument with the id, installation_id and pem_file in the provider configuration. The owner parameter is also required in this situation. - Set the
GITHUB_APP_ID
,GITHUB_APP_INSTALLATION_ID
andGITHUB_APP_PEM_FILE
environment variables. The provider can read the GITHUB_APP_ID, GITHUB_APP_INSTALLATION_ID and GITHUB_APP_PEM_FILE environment variables to authenticate.
Because strings with new lines is not support:
use "\\n" within thepem_file
argument to replace new line
use "\n" within theGITHUB_APP_PEM_FILE
environment variables to replace new line
- Create and manage repositories within your GitHub organization or personal account.
- Configure branch protection for repositories in your organization or personal account.
- Create and manage GitHub Actions secrets within your GitHub repositories.
- Enable and manage GitHub Actions permissions for your GitHub repository.
- Create and manage branches within your repository.
- create and manage files within a GitHub repository.
module "repository" {
source = "app.terraform.io/ConseilsTI/repository/github"
version = "0.0.0"
name = "Repository Name"
destination_type = "This is a description for the GitHub repository."
branch_protections = [
{
pattern = "main"
enforce_admins = true
require_conversation_resolution = true
required_pull_request_reviews = {
dismiss_stale_reviews = true
require_code_owner_reviews = true
required_approving_review_count = "1"
}
}
]
actions_secrets = [
{
secret_name = "Secret Name"
plaintext_value = "Secret Value"
}
]
allowed_actions = "selected"
allowed_actions_config = {
github_owned_allowed = true
patterns_allowed = ["terraform-docs/gh-actions@*", "hashicorp/*"]
}
files = [
{
file = "README.md"
content = "# README"
}
]
}