Skip to content

Commit 9472c95

Browse files
committed
refactor: settings deploy key for repository (#29)
1 parent 5c22e1f commit 9472c95

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

main.tf

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ locals {
1717
topics = []
1818
vulnerability_alerts = true
1919
}
20+
2021
confs = merge(local.settings, var.settings)
2122
}
2223

@@ -73,11 +74,11 @@ resource "github_repository" "this" {
7374
# Add a deploy key
7475
resource "github_repository_deploy_key" "this" {
7576
depends_on = [github_repository.this]
76-
count = try(var.key, null) != null ? 1 : 0
77-
title = var.name
77+
count = length(var.deploy_keys)
78+
title = var.deploy_keys[count.index].title
7879
repository = github_repository.this.name
79-
key = file(var.key)
80-
read_only = var.read_only
80+
key = file(var.deploy_keys[count.index].key)
81+
read_only = lookup(var.deploy_keys[count.index], "read_only", true)
8182
}
8283

8384
resource "github_actions_secret" "this" {

variables.tf

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ variable "visibility" {
1414
default = "private"
1515
}
1616

17-
variable "key" {
18-
type = string
19-
description = "filename pub for repository deploy key."
20-
default = null
21-
}
22-
23-
variable "read_only" {
24-
type = bool
25-
description = "enabled read_only or no."
26-
default = true
17+
variable "deploy_keys" {
18+
type = list(object({
19+
title = string
20+
key = string
21+
read_only = bool
22+
}))
23+
description = "The name of repositories."
24+
default = []
2725
}
2826

2927
variable "secrets" {

0 commit comments

Comments
 (0)