-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfiles.tf
More file actions
75 lines (66 loc) · 2.6 KB
/
files.tf
File metadata and controls
75 lines (66 loc) · 2.6 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# ---------------------------------------------------------------------------------------------------------------------
# Computations
# ---------------------------------------------------------------------------------------------------------------------
# GitHub does not like empty files, so make sure no file is empty
locals {
files_strict = { for file_path, file_content in var.files_strict :
file_path => file_content == "" ? " " : file_content if !(var.dotfiles_first && can(regex("^\\.", file_path)))
}
files = { for file_path, file_content in var.files :
file_path => file_content == "" ? " " : file_content if !(var.dotfiles_first && can(regex("^\\.", file_path)))
}
dotfiles_strict = { for file_path, file_content in var.files_strict :
file_path => file_content == "" ? " " : file_content if var.dotfiles_first && can(regex("^\\.", file_path))
}
dotfiles = { for file_path, file_content in var.files :
file_path => file_content == "" ? " " : file_content if var.dotfiles_first && can(regex("^\\.", file_path))
}
}
# ---------------------------------------------------------------------------------------------------------------------
# Resources
# ---------------------------------------------------------------------------------------------------------------------
resource "github_repository_file" "dotfiles_strict" {
for_each = local.dotfiles_strict
repository = local.repo.name
branch = local.repo.default_branch
file = each.key
content = each.value
overwrite_on_create = true
}
resource "github_repository_file" "dotfiles" {
for_each = local.dotfiles
repository = local.repo.name
branch = local.repo.default_branch
file = each.key
content = each.value
overwrite_on_create = true
lifecycle {
ignore_changes = all
}
}
resource "github_repository_file" "files_strict" {
for_each = local.files_strict
depends_on = [
github_actions_secret.secret,
github_repository_file.dotfiles_strict
]
repository = local.repo.name
branch = local.repo.default_branch
file = each.key
content = each.value
overwrite_on_create = true
}
resource "github_repository_file" "files" {
for_each = local.files
depends_on = [github_actions_secret.secret,
github_repository_file.dotfiles
]
repository = local.repo.name
branch = local.repo.default_branch
file = each.key
content = each.value
overwrite_on_create = true
lifecycle {
ignore_changes = all
}
}