Skip to content

Commit 8de6539

Browse files
authored
feat:check and output invalid users (#133)
1 parent cc9b8d0 commit 8de6539

File tree

7 files changed

+24
-28
lines changed

7 files changed

+24
-28
lines changed

.github/workflows/apply.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
paths:
88
- 'terraform/production/*.tfvars'
9+
- 'terraform/*.tf'
910

1011
concurrency:
1112
group: terraform-actions

.github/workflows/plan.yml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
- main
66
paths:
77
- 'terraform/production/*.tfvars'
8+
- 'terraform/*.tf'
89

910
concurrency:
1011
group: terraform-actions

terraform/README.md

-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ All changes should be made in `production/*.tfvars`:
5151
topics = []
5252
visibility = "public" # optional, default is "public"
5353
is_django_commons_repo = optional(bool, false) # Do not create teams for repository
54-
enable_branch_protection = true # optional, default is true
5554
required_status_checks_contexts = [] # optional, default is []
5655
admins = [] # Members of the repository's admin and repository teams. Have admin permissions
5756
committers = [] # Members of the repository's committers and repository teams. Have write permissions

terraform/locals.tf

-15
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,6 @@
33

44
locals {
55

6-
admins = {
7-
for user in var.admins : user => "admin"
8-
}
9-
10-
branch_protections = {
11-
for repository_key, repository in var.repositories : repository_key => repository
12-
if repository.enable_branch_protection
13-
}
14-
15-
members = {
16-
for user in var.members : user => "member"
17-
}
18-
19-
users = merge(local.admins, local.members)
20-
216
project_repositories = {
227
for repository_key, repository in var.repositories : repository_key => repository
238
if !repository.is_django_commons_repo

terraform/production/repositories.tfvars

+8-11
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
repositories = {
33

44
".github" = {
5-
description = "A Special Repository."
6-
enable_branch_protection = false
5+
description = "A Special Repository."
76

87
topics = []
98
push_allowances = []
109
is_django_commons_repo = true
1110
}
1211

1312
"controls" = {
14-
description = "The controls for managing Django Commons projects"
15-
enable_branch_protection = false
16-
allow_merge_commit = true
17-
allow_rebase_merge = true
18-
allow_squash_merge = true
19-
topics = []
20-
push_allowances = []
21-
is_django_commons_repo = true
13+
description = "The controls for managing Django Commons projects"
14+
allow_merge_commit = true
15+
allow_rebase_merge = true
16+
allow_squash_merge = true
17+
topics = []
18+
push_allowances = []
19+
is_django_commons_repo = true
2220
}
2321

2422
"membership" = {
@@ -162,7 +160,6 @@ repositories = {
162160
"tailwindcss",
163161
]
164162
visibility = "public"
165-
enable_branch_protection = true
166163
required_status_checks_contexts = []
167164
admins = [
168165
"oliverandrich",

terraform/resources-org.tf

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# GitHub Membership Resource
22
# https://registry.terraform.io/providers/integrations/github/latest/docs/resources/membership
3+
data "github_users" "users" {
4+
usernames = setunion(var.admins, var.members)
5+
}
6+
7+
output "invalid_users" {
8+
value = data.github_users.users.unknown_logins
9+
}
10+
11+
locals {
12+
users = merge(
13+
{ for user in var.admins : user => "admin" if contains(data.github_users.users.logins, user) },
14+
{ for user in var.members : user => "member" if contains(data.github_users.users.logins, user) }
15+
)
16+
}
317

418
resource "github_membership" "this" {
519
for_each = local.users

terraform/variables.tf

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ variable "repositories" {
3333
homepage_url = optional(string, "")
3434
has_wiki = optional(bool, false)
3535
push_allowances = optional(list(string), [])
36-
enable_branch_protection = optional(bool, true)
3736
required_status_checks_contexts = optional(list(string), [])
3837
is_template = optional(bool, false) # Is the repository a template repository
3938
topics = optional(list(string))

0 commit comments

Comments
 (0)