-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathmain.tf
90 lines (78 loc) · 2.96 KB
/
main.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
data "github_team" "push_teams" {
count = "${length(var.push_teams)}"
slug = "${element(var.push_teams, count.index)}"
}
data "github_team" "pull_teams" {
count = "${length(var.pull_teams)}"
slug = "${element(var.pull_teams, count.index)}"
}
data "github_team" "admin_teams" {
count = "${length(var.admin_teams)}"
slug = "${element(var.admin_teams, count.index)}"
}
resource "github_repository" "main" {
name = "${var.name}"
description = "${var.description}"
homepage_url = "${var.homepage_url}"
private = "${var.private}"
has_issues = "${var.has_issues}"
has_wiki = "${var.has_wiki}"
allow_merge_commit = "${var.allow_merge_commit}"
allow_squash_merge = "${var.allow_squash_merge}"
allow_rebase_merge = "${var.allow_rebase_merge}"
has_downloads = "${var.has_downloads}"
auto_init = "${var.auto_init}"
gitignore_template = "${var.gitignore_template}"
license_template = "${var.license_template}"
default_branch = "${var.default_branch}"
}
resource "github_branch_protection" "main" {
repository = "${github_repository.main.name}"
branch = "${github_repository.main.default_branch}"
enforce_admins = true
required_status_checks {
strict = "${var.force_pr_rebase}"
contexts = "${var.status_checks_contexts}"
}
required_pull_request_reviews {
dismiss_stale_reviews = true
dismissal_users = ["${var.dismiss_review_users}"]
require_code_owner_reviews = true
}
}
resource "github_team_repository" "push" {
count = "${length(data.github_team.push_teams.*.id)}"
team_id = "${element(data.github_team.push_teams.*.id, count.index)}"
repository = "${github_repository.main.name}"
permission = "push"
}
resource "github_team_repository" "pull" {
count = "${length(data.github_team.pull_teams.*.id)}"
team_id = "${element(data.github_team.pull_teams.*.id, count.index)}"
repository = "${github_repository.main.name}"
permission = "pull"
}
resource "github_team_repository" "admin" {
count = "${length(data.github_team.admin_teams.*.id)}"
team_id = "${element(data.github_team.admin_teams.*.id, count.index)}"
repository = "${github_repository.main.name}"
permission = "admin"
}
resource "github_repository_collaborator" "push" {
repository = "${github_repository.main.name}"
count = "${length(var.push_collaborators)}"
username = "${element(var.push_collaborators, count.index)}"
permission = "push"
}
resource "github_repository_collaborator" "pull" {
repository = "${github_repository.main.name}"
count = "${length(var.pull_collaborators)}"
username = "${element(var.pull_collaborators, count.index)}"
permission = "pull"
}
resource "github_repository_collaborator" "admin" {
repository = "${github_repository.main.name}"
count = "${length(var.admin_collaborators)}"
username = "${element(var.admin_collaborators, count.index)}"
permission = "admin"
}