-
Notifications
You must be signed in to change notification settings - Fork 0
/
actions.tf
55 lines (50 loc) · 2.17 KB
/
actions.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
locals {
action_names = keys(var.actions)
actions_enabled = var.enabled && length(local.action_names) > 0
}
data "null_data_source" "actions" {
count = var.enabled ? length(var.actions) : 0
inputs = {
key = "templates/actions/${local.action_names[count.index]}.yaml"
value = jsonencode({
target = format(".github/workflows/%s.yaml", replace(local.action_names[count.index], "/", "-"))
data = var.actions[local.action_names[count.index]]
})
}
}
module "initial_actions_commit" {
source = "git::https://github.com/goci-io/terraform-git-commit.git?ref=tags/0.4.0"
commit_depends_on = [module.sync_additional_commit]
git_repository = local.repository_name
git_organization = var.github_organization
git_base_url = var.github_base_url
ssh_key_file = local.ssh_key_file_path
templates_root_dir = abspath(path.module)
repository_checkout_dir = var.repository_checkout_dir
enabled = local.actions_enabled && var.create_repository
message = "[goci] add initial github actions"
branch = "master"
changes = false
paths = zipmap(
data.null_data_source.actions.*.outputs.key,
jsondecode(format("[%s]", join(",", data.null_data_source.actions.*.outputs.value)))
)
}
module "sync_actions_commit" {
source = "git::https://github.com/goci-io/terraform-git-commit.git?ref=tags/0.4.0"
commit_depends_on = [module.initial_actions_commit]
git_repository = local.repository_name
git_organization = var.github_organization
git_base_url = var.github_base_url
ssh_key_file = local.ssh_key_file_path
repository_checkout_dir = var.repository_checkout_dir
templates_root_dir = abspath(path.module)
message = "[goci] update github actions"
branch = "goci-update-actions"
changes = true
enabled = local.actions_enabled
paths = zipmap(
data.null_data_source.actions.*.outputs.key,
jsondecode(format("[%s]", join(",", data.null_data_source.actions.*.outputs.value)))
)
}