https://github.com/uplink-systems/terraform-module-github-repository
Terraform module to manage GitHub repositories
https://github.com/uplink-systems/terraform-module-github-repository
github terraform
Last synced: about 2 months ago
JSON representation
Terraform module to manage GitHub repositories
- Host: GitHub
- URL: https://github.com/uplink-systems/terraform-module-github-repository
- Owner: uplink-systems
- License: eupl-1.2
- Created: 2025-01-09T10:24:03.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-22T14:40:23.000Z (over 1 year ago)
- Last Synced: 2025-01-25T07:12:33.047Z (over 1 year ago)
- Topics: github, terraform
- Language: HCL
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Module 'terraform-module-github-repository'
### Description
The **terraform-module-github-repository** is intended to create and manage GitHub repository resources following my business needs and standards.
This includes the following guidelines:
* Repository names
* Names of GitHub repositories are lowercase and can contain the following characters only:
* "a-z", "0-9", ".", "-"
### Requirements
| Name | Version |
|------|---------|
| [terraform](#requirement\_terraform) | >= 1.13.0 |
| [integrations\/github](#requirement\_github) | ~> 6.11.0 |
| [hashicorp\/time](#requirement\_time) | ~> 0.13.0 |
### Resources
| Name | Type |
|------|------|
| [github_repository.repository](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository) | resource |
| [github_repository_collaborator.repository_collaborator](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_collaborator) | resource |
| [github_team_repository.team_repository](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/team_repository) | resource |
| [github_branch.branch](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch) | resource |
| [github_branch_default.branch_default](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_default) | resource |
| [time_offset.offset](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/offset) | resource |
| [github_repository_milestone.repository_milestone](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository_milestone) | resource |
| [github_issue_label.issue_label](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/issue_label) | resource |
| [github_issue.issue](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/issue) | resource |
| [github_release.release](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/release) | resource |
### Inputs
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [repository](#input\_repository) | 'var.repository' is the main variable for github_repository resource settings |
type = object({
name = string
description = optional(string, null)
allow_auto_merge = optional(bool, false)
allow_merge_commit = optional(bool, true)
allow_rebase_merge = optional(bool, true)
allow_squash_merge = optional(bool, true)
allow_update_branch = optional(bool, false)
archive_on_destroy = optional(bool, null)
archived = optional(bool, null)
auto_init = optional(bool, true)
delete_branch_on_merge = optional(bool, false)
gitignore_template = optional(string, null)
has_discussions = optional(bool, false)
has_downloads = optional(bool, false)
has_issues = optional(bool, false)
has_projects = optional(bool, false)
has_wiki = optional(bool, false)
homepage_url = optional(string, null)
ignore_vulnerability_alerts_during_read = optional(bool, false)
is_template = optional(bool, false)
license_template = optional(string, null)
pages = optional(any, null)
security_and_analysis = optional(any, null)
template = optional(object({
owner = string
repository = string
include_all_branches = optional(bool, false)
}), null)
topics = optional(list(string), null)
visibility = optional(string, null)
vulnerability_alerts = optional(bool, null)
web_commit_signoff_required = optional(bool, false)
})
| none | yes |
| [repository\_collaborator](#input\_repository\_collaborator) | 'var.repository_collaborator' specifies lists of different collaborator types for the repository | type = object({
enabled = optional(bool, true)
admin = optional(list(string), [])
maintain = optional(list(string), [])
pull = optional(list(string), [])
push = optional(list(string), [])
triage = optional(list(string), [])
})
|{ enabled = false } | no |
| [team\_repository](#input\_team\_repository) | 'var.team_repository' specifies lists of different team names for the repository | type = object({
enabled = optional(bool, true)
admin = optional(list(string), [])
maintain = optional(list(string), [])
pull = optional(list(string), [])
push = optional(list(string), [])
triage = optional(list(string), [])
})
| { enabled = false } | no |
| [branch](#input\_branch) | 'var.branch' is the optional variable for additional github_branch resource settings | type = list(object({
branch = string
source_branch = optional(string, null)
source_sha = optional(string, null)
}))
| [ ]
| no |
| [branch\_default](#input\_branch\_default) | 'var.branch_default' is the optional variable for the github_branch_default resource settings | type = object({
branch = string
})
| none | no |
| [repository\_milestone](#input\_repository\_milestone) | 'var.repository_milestone' is the optional variable for the github_repository_milestone resource settings | type = map(object({
owner = string
title = string
description = optional(string, null)
due_date = optional(string, null)
state = optional(string, "open")
}))
| { } | no |
| [issue\_label](#input\_issue\_label) | 'var.issue_label' is the optional variable for the github_issue_label resource settings | type = object({
merge = optional(bool, null)
label = optional(list(object({
name = string
color = string
description = string
})), [])
})
| { merge = false } | no |
| [issue](#input\_issue) | 'var.issue' is the optional variable for the github_issue resource settings | type = map(object({
title = string
body = optional(string, null)
labels = optional(list(string), [])
assignees = optional(list(string), [])
milestone_number = optional(number, null)
}))
| { } | no |
| [release](#input\_release) | 'var.release' is the optional variable for the github_release resource settings | type = map(object({
tag_name = string
name = optional(string, null)
target_commitish = optional(string, null)
body = optional(string, null)
generate_release_notes = optional(bool, null)
draft = optional(bool, null)
prerelease = optional(bool, null)
discussion_category_name = optional(string, null)
}))
| { } | no |
### Outputs
| Name | Description |
|------|-------------|
| [github\_repository](#output\_github\_repository) | list of all exported attributes values from the repository resource(s) |
| [github\_repository\_collaborator](#output\_github\_repository\_collaborator) | list of all exported attributes values from the repository_collaborator resource(s) |
| [github\_team\_repository](#output\_github\_team\_repository) | list of all exported attributes values from the team_repository resource(s) |
| [github\_branch](#output\_github\_branch) | list of all exported attributes values from the branch resource(s) |
| [github\_branch\_default](#output\_github\_branch\_default) | list of all exported attributes values from the branch_default resource(s) |
| [github\_repository\_milestone](#output\_github\_repository\_milestone) | list of all exported attributes values from the repository_milestone resource(s) |
| [github\_issue\_label](#output\_github\_issue\_issue) | list of all exported attributes values from the issue_label resource(s) |
| [github\_issue](#output\_github\_issue) | list of all exported attributes values from the issue resource(s) |
| [github\_release](#output\_github\_release) | list of all exported attributes values from the release resource(s) |
### Known Issues
Known issues are documented with the GitHub repo's issues functionality. Please filter the issues by **Types** and select **Known Issue** to get the appropriate issues and read the results carefully before using the module to avoid negative impacts on your infrastructure.
[list of Known Issues](https://github.com/uplink-systems/terraform-module-github-repository/issues?q=type%3A%22known%20issue%22)
### Notes / Hints / HowTos
Lifecycle values
######
* 'repository_milestone' resource -> the module ignores changes of the 'state' attribute because the state should be maintained by the repository's members after initial creation
* 'issue' resource -> the module ignores changes of the 'body' attribute because the issue's body/description should be maintained by the issue's owners after initial creation
######
Variable setting 'issue_label.merge'
######
The variable setting 'issue_label.merge' can be used to manage the GitHub's default issue labels in addition to the custom created ones.
How it works:
- The default value for the setting is 'false' if no custom issue label is specified to create as this situation implies that issue labels shall not be managed. Setting the value manually to 'true' adds the default GitHub issue labels to Terraform state during next apply and allows them to be managed.
- The default value for the setting is 'null' if one or more custom issue labels are specified to create. A 'null' value equals a 'true' value for the module and therefore adds the default GitHub issue labels to Terraform state and allows them to be managed. Setting the variable manually to 'false' skips importing the default issue labels.
The variable setting also allows the admin to REMOVE the GitHub default issue labels. This can be done by setting the value to 'true' and apply. After successfull apply the value must be set to 'false' and applied again. This adds the existing default issue labels to Terraform state during first apply and destroys the issue labels (and removes it from GitHub) during second apply. Changing the variable setting to 'true' again restores the default issue labels again.
######