Skip to content

Infrastrukturait/terraform-github-repository

Repository files navigation

terraform-github-repository

WeSupportUkraine

About

A 1 module for creating a public or private repository on 2.

License

License: MIT

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Source: <https://opensource.org/licenses/MIT>

See LICENSE for full details.

Authors

Documentation

Requirements

Name Version
terraform >= 0.14
github >= 4.20, < 6.0

Modules

No modules.

Resources

Name Type
github_actions_secret.repository_secret resource
github_app_installation_repository.app_installation_repository resource
github_branch.branch resource
github_branch_default.default resource
github_branch_protection_v3.branch_protection resource
github_issue_label.label resource
github_repository.repository resource
github_repository_autolink_reference.repository_autolink_reference resource
github_repository_collaborator.collaborator resource
github_repository_deploy_key.deploy_key resource
github_repository_deploy_key.deploy_key_computed resource
github_repository_project.repository_project resource
github_repository_webhook.repository_webhook resource
github_team_repository.team_repository resource
github_team_repository.team_repository_by_slug resource

Inputs

Name Description Type Default Required
admin_collaborators A list of users to add as collaborators granting them admin full permission. list(string) [] no
admin_team_ids A list of teams (by id) to grant admin full permission to. list(string) [] no
admin_teams A list of teams (by name/slug) to grant admin full permission to. list(string) [] no
allow_auto_merge Set to true to allow auto-merging pull requests on the repository.
If enabled for a pull request, the pull request will mergeautomatically when all required reviews are met and status checks have passed.
bool false no
allow_merge_commit Set to false to disable merge commits on the repository. bool true no
allow_rebase_merge Set to true to enable rebase merges on the repository. bool false no
allow_squash_merge Set to true to enable squash merges on the repository. bool false no
app_installations (Optional) A list of GitHub App IDs to be installed in this repository. set(string) [] no
archive_on_destroy Set to false to not archive the repository instead of deleting on destroy. string true no
archived (Optional) Specifies if the repository should be archived. (Default: false) bool false no
auto_init Wether or not to produce an initial commit in the repository. bool true no
autolink_references Configuring autolink references. For details please check: 7
Example:
autolink_references = [
{
key_prefix = "TICKET-"
target_url_template = "https://hello.there/TICKET?query="
}
]
list(object({
key_prefix = string
target_url_template = string
}))
[] no
branch_protections_v3 A list of branch protections to apply to the repository.
We can't use a detailed type specification due to a terraform limitation. However, this might be changed in a future Terraform version.
See 8 and 9.
type = list(object({
branch = string
enforce_admins = bool
require_signed_commits = bool
required_status_checks = object({
strict = bool
contexts = list(string)
})
required_pull_request_reviews = object({
dismiss_stale_reviews = bool
dismissal_users = list(string)
dismissal_teams = list(string)
require_code_owner_reviews = bool
required_approving_review_count = number
})
restrictions = object({
users = list(string)
teams = list(string)
})
}))
Example:
branch_protections = [
{
branch = "main"
enforce_admins = true
require_signed_commits = true

required_status_checks = {
strict = false
contexts = ["ci/travis"]
}

required_pull_request_reviews = {
dismiss_stale_reviews = true
dismissal_users = ["user1", "user2"]
dismissal_teams = ["team-slug-1", "team-slug-2"]
require_code_owner_reviews = true
required_approving_review_count = 1
}

restrictions = {
users = ["user1"]
teams = ["team-slug-1"]
}
}
]
any null no
branches A list of branches to be created in this repository. any [] no
default_branch The name of the default branch of the repository.
NOTE: This can only be set after a repository has already been created, and after acorrect reference has been created for the target branch inside the repository.
This means a user will have to omit this parameter from the initial repositorycreation and create the target branch inside of the repository prior to setting this attribute.
string null no
delete_branch_on_merge Whether or not to delete the merged branch after merging a pull request. bool false no
deploy_keys Configure a deploy key ( SSH key ) that grants access to a single GitHub repository.
This key is attached directly to the repositoryinstead of to a personal user account.
any [] no
deploy_keys_computed Configure a deploy key ( SSH key ) that grants access to a single GitHub repository.
This key is attached directly to the repository instead of to a personal user account.
Example:
`
deploy_keys_computed = [
{
title = "CI User Deploy Key"
key = computed.resource
read_only = true
}
]
any [] no
description A description of the repository. string "" no
encrypted_secrets Configuring encrypted actions secrets. For details please check: 6.
Example:
encrypted_secrets = {
"MY_ENCRYPTED_SECRET" = "MTIzNDU="
}
map(string) {} no
gitignore_template Use the name of the template without the extension. For example, Haskell, Terraform or Python.
Available templates: 3
string null no
has_downloads Set to true to enable the deprecated downloads features on the repository. bool false no
has_issues Set to true to enable the GitHub Issues features on the repository. bool false no
has_projects Set to true to enable the GitHub Projects features on the repository.
Per the github documentation when in an organization that has disabled repository projects it will default to false and will otherwise default to true.
If you specify true when it has been disabled it will return an error.
bool false no
has_wiki Set to true to enable the GitHub Wiki features on the repository. bool false no
homepage_url The website of the repository. string null no
is_template Whether or not to tell GitHub that this is a template repository. bool false no
issue_labels Configure a GitHub issue label resource.
Example:
issue_labels = [
{
name = "WIP"
description = "Work in Progress..."
color = "d6c860"
},
{
name = "another-label"
description = "This is a lable created by Terraform..."
color = "1dc34f"
}
]
list(object({
name = string
description = string
color = string
}))
[] no
issue_labels_create Specify whether you want to force or suppress the creation of issues labels. bool null no
issue_labels_merge_with_github_labels Specify if you want to merge and control githubs default set of issue labels. bool null no
license_template Use the name of the template without the extension. For example, 'mit' or 'mpl-2.0'.
Available licences: 4
string null no
maintain_collaborators A list of users to add as collaborators granting them maintain permission. list(string) [] no
maintain_team_ids A list of teams (by id) to grant maintain permission to. list(string) [] no
maintain_teams A list of teams (by name/slug) to grant maintain permission to. list(string) [] no
name The name of the repository. string n/a yes
pages The repository's GitHub Pages configuration. any {} no
plaintext_secrets Configuring actions secrets. For details please check: 6.
Example:
plaintext_secrets = {
"MY_SECRET" = "42"
"OWN_TOKEN" = "12345"
}
map(string) {} no
projects Create and manage projects for GitHub repository.
Example:
projects = [
{
name = "Testproject"
body = "This is a fancy test project for testing"
}
]
list(object({
name = string
body = string
}))
[] no
pull_collaborators A list of users to add as collaborators granting them pull read-only permission. list(string) [] no
pull_team_ids (Optional) A list of teams (by id) to grant pull read-only permission to. list(string) [] no
pull_teams A list of teams (by name/slug) to grant pull read-only permission to. list(string) [] no
push_collaborators A list of users to add as collaborators granting them push read-write permission. list(string) [] no
push_team_ids A list of teams (by id) to grant push read-write permission to. list(string) [] no
push_teams A list of teams (by name/slug) to grant push read-write permission to. list(string) [] no
template Template repository to use.
object({
owner = string
repository = string
})
null no
topics The list of topics of the repository. list(string) [] no
triage_collaborators A list of users to add as collaborators granting them triage permission. list(string) [] no
triage_team_ids A list of teams (by id) to grant triage permission to. list(string) [] no
triage_teams A list of teams (by name/slug) to grant triage permission to. list(string) [] no
visibility Can be public, private or internal (GH Enterprise only). The visibility parameter overrides the private parameter.
Defaults to private if neither private nor visibility are set, default to state of private parameter if it is set.
string "private" no
vulnerability_alerts Set to false to disable security alerts for vulnerable dependencies. Enabling requires alerts to be enabled on the owner level. bool null no
webhooks Configuring webhooks.
For details please check: 5.
We can't use a detailed type specification due to a terraform limitation. However, this might be changed in a future Terraform version.
See 8 and 9
type = list(object({
name = string
active = bool
events = list(string)
url = string
content_type = string
insecure_ssl = bool
secret = string
}))
Example:
webhooks = [{
active = false
events = ["issues"]
url = "https://google.de/"
content_type = "form"
insecure_ssl = false
}]
any [] no

Outputs

Name Description
app_installations A map of deploy app installations keyed by installation id.
branches A map of branch objects keyed by branch name.
collaborators A map of collaborator objects keyed by collaborator.name.
deploy_keys A map of deploy keys keyed by input id.
full_name A string of the form 'orgname/reponame'.
git_clone_url URL that can be provided to git clone to clone the repository anonymously via the git protocol.
html_url URL to the repository on the web.
http_clone_url URL that can be provided to git clone to clone the repository via HTTPS.
issue_labels A map of issue labels keyed by label input id or name.
projects A map of projects keyed by project input id.
repository All attributes and arguments as returned by the github_repository resource.
secrets List of secrets available.
ssh_clone_url URL that can be provided to git clone to clone the repository via SSH.
webhooks All attributes and arguments as returned by the github_repository_webhook resource.

Examples

# complete example - main.tf

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages