Skip to content

Commit bc499d9

Browse files
committed
feat: add support for the github_app_installation_repository resource
1 parent 0037dba commit bc499d9

File tree

9 files changed

+77
-0
lines changed

9 files changed

+77
-0
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ jobs:
4949
env:
5050
GITHUB_OWNER: ${{ secrets.TEST_GITHUB_ORGANIZATION }}
5151
GITHUB_TOKEN: ${{ secrets.TEST_GITHUB_TOKEN }}
52+
TF_VAR_app_installations: ${{ secrets.TEST_GITHUB_APP_INSTALLATIONS }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Added
11+
12+
- Add support for `github_app_installation_repository`
13+
1014

1115
## [0.16.0]
1216

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ _Security related notice: Versions 4.7.0, 4.8.0, 4.9.0 and 4.9.1 of the Terrafor
3333
- [Webhooks Configuration](#webhooks-configuration)
3434
- [Secrets Configuration](#secrets-configuration)
3535
- [Autolink References Configuration](#autolink-references-configuration)
36+
- [App Installations](#app-installations)
3637
- [Module Configuration](#module-configuration)
3738
- [Module Outputs](#module-outputs)
3839
- [External Documentation](#external-documentation)
@@ -808,6 +809,20 @@ This is due to some terraform limitation and we will update the module once terr
808809

809810
The template of the target URL used for the links; must be a valid URL and contain `<num>` for the reference number.
810811

812+
#### App Installations
813+
814+
- [**`app_installations`**](#var-app_installations): *(Optional `set(number)`)*<a name="var-app_installations"></a>
815+
816+
A set of GitHub App IDs to be installed in this repository.
817+
818+
Default is `{}`.
819+
820+
Example:
821+
822+
```hcl
823+
app_installations = [25405144, 12556423]
824+
```
825+
811826
### Module Configuration
812827

813828
- [**`module_depends_on`**](#var-module_depends_on): *(Optional `list(dependency)`)*<a name="var-module_depends_on"></a>
@@ -886,6 +901,10 @@ The following attributes are exported by the module:
886901

887902
List of secrets available.
888903

904+
- [**`app_installations`**](#output-app_installations): *(`set(number)`)*<a name="output-app_installations"></a>
905+
906+
A map of deploy app installations keyed by installation id.
907+
889908
## External Documentation
890909

891910
### Terraform Github Provider Documentation

README.tfdoc.hcl

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,6 +1052,22 @@ section {
10521052
}
10531053
}
10541054
}
1055+
1056+
section {
1057+
title = "App Installations"
1058+
1059+
variable "app_installations" {
1060+
type = set(number)
1061+
default = {}
1062+
description = <<-END
1063+
A set of GitHub App IDs to be installed in this repository.
1064+
END
1065+
1066+
readme_example = <<-END
1067+
app_installations = [25405144, 12556423]
1068+
END
1069+
}
1070+
}
10551071
}
10561072

10571073
section {
@@ -1177,6 +1193,13 @@ section {
11771193
List of secrets available.
11781194
END
11791195
}
1196+
1197+
output "app_installations" {
1198+
type = set(number)
1199+
description = <<-END
1200+
A map of deploy app installations keyed by installation id.
1201+
END
1202+
}
11801203
}
11811204

11821205
section {

main.tf

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,3 +496,14 @@ resource "github_repository_autolink_reference" "repository_autolink_reference"
496496
key_prefix = each.value.key_prefix
497497
target_url_template = each.value.target_url_template
498498
}
499+
500+
# ---------------------------------------------------------------------------------------------------------------------
501+
# App installation
502+
# ---------------------------------------------------------------------------------------------------------------------
503+
504+
resource "github_app_installation_repository" "app_installation_repository" {
505+
for_each = { for a in var.app_installations : a => a }
506+
507+
repository = github_repository.repository.name
508+
installation_id = each.value
509+
}

outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ output "secrets" {
7979
description = "List of secrets available."
8080
}
8181

82+
output "app_installations" {
83+
value = github_app_installation_repository.app_installation_repository
84+
description = "A map of deploy app installations keyed by installation id."
85+
}
86+
8287
# ----------------------------------------------------------------------------------------------------------------------
8388
# OUTPUT MODULE CONFIGURATION
8489
# ----------------------------------------------------------------------------------------------------------------------

test/unit-complete/main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ module "repository" {
132132
projects = var.projects
133133

134134
autolink_references = var.autolink_references
135+
136+
app_installations = var.app_installations
135137
}
136138

137139
# ---------------------------------------------------------------------------------------------------------------------

test/unit-complete/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,9 @@ variable "autolink_references" {
255255
target_url_template = "https://hello.there/TICKET?query=<num>"
256256
}]
257257
}
258+
259+
variable "app_installations" {
260+
type = set(number)
261+
description = "A list of GitHub App IDs to be installed in this repository."
262+
default = []
263+
}

variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,12 @@ variable "archive_on_destroy" {
528528
default = true
529529
}
530530

531+
variable "app_installations" {
532+
type = set(number)
533+
description = "(Optional) A list of GitHub App IDs to be installed in this repository."
534+
default = []
535+
}
536+
531537
# ------------------------------------------------------------------------------
532538
# MODULE CONFIGURATION PARAMETERS
533539
# These variables are used to configure the module.

0 commit comments

Comments
 (0)