Skip to content

Commit da92157

Browse files
authored
Initial implementation (#1)
* Intial implementation * Fix variables * Fix hcl formatiing * Fix hcl formatiing * Fix hcl formatiing * Fix hcl formatiing * Fix hcl formatiing * Fix tests * Fix tests * Addded validations * Fix formatiing * Fix formatiing * Fix formatiing * Fix formatiing * Fix fomatting * Simplify tests * Added tests and validations * Fix formatting * Fix formatting * Fix formatting * Fix formatting * Fix formatting * Added readme * Added readme * Added readme * Added templates and output * Added outputs * Fix formatting * Fix formatting * Update main.tf * Update main.tf * Update main.tf
1 parent d2a19dd commit da92157

23 files changed

Lines changed: 3864 additions & 175 deletions

.github/settings.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Upstream changes from _extends are only recognized when modifications are made to this file in the default branch.
22
_extends: .github
33
repository:
4-
name: terraform-example-module
5-
description: Example Terraform Module Scaffolding
4+
name: terraform-github-repository
5+
description: Terraform Module to provision a GitHub Repository
66
homepage: https://cloudposse.com/accelerate
7-
topics: ""
8-
9-
10-
11-
12-
7+
topics:
8+
- terraform
9+
- github
10+
- repository
11+
- automation
12+
- automation-as-code
13+
- ci/cd

README.md

Lines changed: 118 additions & 46 deletions
Large diffs are not rendered by default.

README.yaml

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
1-
# DELETE ME
2-
#
3-
# The above is the README configuration for the Example module itself.
4-
# Delete from here to the top of file and fill in the template below
5-
########################################################################################################################
6-
########################################################################################################################
7-
########################################################################################################################
8-
1+
# Name of this project
2+
name: terraform-github-repository
3+
# Canonical GitHub repo
4+
github_repo: cloudposse/terraform-github-repository
95

10-
#
11-
# This is the canonical configuration for the `README.md`
12-
# Run `make readme` to rebuild the `README.md`
13-
#
6+
tags:
7+
- terraform
8+
- terraform-modules
9+
- github
10+
- repository
1411

15-
# Name of this project
16-
name: terraform-example-module
12+
categories:
13+
- terraform-modules/github
1714

1815
# Logo for this project
1916
#logo: docs/logo.png
@@ -27,16 +24,14 @@ copyrights:
2724
url: "https://cloudposse.com"
2825
year: "2021"
2926

30-
# Canonical GitHub repo
31-
github_repo: cloudposse/terraform-example-module
3227

3328
# Badges to display
3429
badges:
3530
- name: Latest Release
36-
image: https://img.shields.io/github/release/cloudposse/terraform-example-module.svg?style=for-the-badge
37-
url: https://github.com/cloudposse/terraform-example-module/releases/latest
31+
image: https://img.shields.io/github/release/cloudposse/terraform-github-repository.svg?style=for-the-badge
32+
url: https://github.com/cloudposse/terraform-github-repository/releases/latest
3833
- name: Last Updated
39-
image: https://img.shields.io/github/last-commit/cloudposse/terraform-example-module.svg?style=for-the-badge
34+
image: https://img.shields.io/github/last-commit/cloudposse/terraform-github-repository.svg?style=for-the-badge
4035
url: https://github.com/cloudposse/terraform-example-module/commits
4136
- name: Slack Community
4237
image: https://slack.cloudposse.com/for-the-badge.svg
@@ -65,39 +60,43 @@ references:
6560

6661
# Short description of this project
6762
description: |-
68-
Short
69-
description
63+
Terraform Module to provision a GitHub Repository with advanced settings.
7064
7165
# Introduction to the project
7266
introduction: |-
73-
This is an introduction.
67+
Terraform Module to provision a GitHub Repository with advanced settings:
68+
69+
* Repository
70+
* Environments
71+
* Deploy Keys
72+
* Rulesets
73+
* Secrets
74+
* Variables
75+
* Custom Properties
76+
* Webhooks
77+
* Autolink References
78+
* Labels
79+
* Collaborators
7480
7581
# How to use this module. Should be an easy example to copy and paste.
7682
usage: |-
7783
For a complete example, see [examples/complete](examples/complete).
7884
79-
For automated tests of the complete example using [bats](https://github.com/bats-core/bats-core) and [Terratest](https://github.com/gruntwork-io/terratest)
80-
(which tests and deploys the example on AWS), see [test](test).
81-
8285
```hcl
83-
# Create a standard label resource. See [null-label](https://github.com/cloudposse/terraform-null-label/#terraform-null-label--)
84-
module "label" {
85-
source = "cloudposse/label/null"
86-
# Cloud Posse recommends pinning every module to a specific version, though usually you want to use the current one
87-
# version = "x.x.x"
88-
89-
namespace = "eg"
90-
name = "example"
91-
}
92-
93-
module "example" {
94-
source = "cloudposse/*****/aws"
86+
module "github_repository" {
87+
source = "cloudposse/repository/github"
9588
# Cloud Posse recommends pinning every module to a specific version
9689
# version = "x.x.x"
9790
98-
example = "Hello world!"
99-
100-
context = module.label.this
91+
name = "my-repository"
92+
description = "My repository"
93+
visibility = "public"
94+
auto_init = true
95+
has_issues = true
96+
has_projects = true
97+
has_wiki = true
98+
has_downloads = true
99+
is_template = false
101100
}
102101
```
103102
@@ -106,10 +105,6 @@ examples: |-
106105
Here is an example of using this module:
107106
- [`examples/complete`](https://github.com/cloudposse/terraform-example-module/) - complete example of using this module
108107
109-
# How to get started quickly
110-
quickstart: |-
111-
Here's how to get started...
112-
113108
# Other files to include in this README from the project folder
114109
include: []
115110
contributors: []
Lines changed: 196 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,202 @@
1-
region = "us-east-2"
1+
owner = "cloudposse-tests"
22

3-
namespace = "eg"
3+
description = "Terraform acceptance tests"
4+
homepage_url = "http://example.com/"
5+
archived = false
6+
has_issues = true
7+
has_discussions = true
8+
has_projects = true
9+
has_wiki = true
10+
has_downloads = true
11+
is_template = true
12+
allow_merge_commit = true
13+
merge_commit_title = "MERGE_MESSAGE"
14+
merge_commit_message = "PR_TITLE"
15+
allow_squash_merge = true
16+
squash_merge_commit_title = "COMMIT_OR_PR_TITLE"
17+
squash_merge_commit_message = "COMMIT_MESSAGES"
18+
web_commit_signoff_required = true
19+
allow_rebase_merge = true
20+
allow_auto_merge = true
21+
delete_branch_on_merge = true
22+
default_branch = "main"
23+
gitignore_template = "TeX"
24+
license_template = "GPL-3.0"
25+
auto_init = true
26+
topics = ["terraform", "github", "test"]
27+
ignore_vulnerability_alerts_during_read = true
28+
allow_update_branch = true
429

5-
environment = "ue2"
30+
security_and_analysis = {
31+
advanced_security = false
32+
secret_scanning = true
33+
secret_scanning_push_protection = true
34+
}
635

7-
stage = "test"
36+
archive_on_destroy = false
837

9-
name = "example"
38+
autolink_references = {
39+
jira = {
40+
key_prefix = "JIRA-"
41+
target_url_template = "https://jira.example.com/browse/<num>"
42+
}
43+
}
1044

11-
example_input = "Hello, world!"
45+
variables = {
46+
test_variable = "test-value"
47+
test_variable_2 = "test-value-2"
48+
}
1249

50+
secrets = {
51+
test_secret = "test-value"
52+
test_secret_2 = "nacl:dGVzdC12YWx1ZS0yCg=="
53+
}
54+
55+
webhooks = {
56+
notify-on-push = {
57+
active = true
58+
url = "https://hooks.example.com/github"
59+
events = ["push", "pull_request"]
60+
content_type = "json"
61+
insecure_ssl = false
62+
secret = "test-secret"
63+
}
64+
}
65+
66+
labels = {
67+
bug2 = {
68+
color = "#a73a4a"
69+
description = "🐛 An issue with the system"
70+
}
71+
feature2 = {
72+
color = "#336699"
73+
description = "New functionality"
74+
}
75+
}
76+
77+
environments = {
78+
staging = {
79+
wait_timer = 1
80+
can_admins_bypass = true
81+
prevent_self_review = true
82+
deployment_branch_policy = {
83+
protected_branches = true
84+
custom_branches = null
85+
}
86+
variables = {
87+
test_variable = "test-value"
88+
test_variable_2 = "test-value-2"
89+
}
90+
}
91+
development = {
92+
wait_timer = 5
93+
can_admins_bypass = false
94+
prevent_self_review = false
95+
variables = {}
96+
}
97+
production = {
98+
wait_timer = 10
99+
can_admins_bypass = false
100+
prevent_self_review = false
101+
deployment_branch_policy = {
102+
protected_branches = false
103+
custom_branches = {
104+
branches = ["main"]
105+
tags = ["v1.0.0"]
106+
}
107+
}
108+
secrets = {
109+
test_secret = "test-value"
110+
test_secret_2 = "nacl:dGVzdC12YWx1ZS0yCg=="
111+
}
112+
}
113+
}
114+
115+
rulesets = {
116+
default = {
117+
name = "Default protection"
118+
enforcement = "active"
119+
target = "branch"
120+
conditions = {
121+
ref_name = {
122+
include = ["~ALL"]
123+
exclude = [
124+
"refs/heads/releases",
125+
"main"
126+
]
127+
}
128+
}
129+
bypass_actors = [
130+
{
131+
bypass_mode = "always"
132+
actor_type = "OrganizationAdmin"
133+
},
134+
{
135+
bypass_mode = "pull_request"
136+
actor_type = "RepositoryRole"
137+
actor_id = "maintain"
138+
},
139+
{
140+
bypass_mode = "pull_request"
141+
actor_type = "RepositoryRole"
142+
actor_id = "write"
143+
},
144+
{
145+
bypass_mode = "pull_request"
146+
actor_type = "RepositoryRole"
147+
actor_id = "admin"
148+
}
149+
]
150+
rules = {
151+
branch_name_pattern = {
152+
operator = "starts_with"
153+
pattern = "release"
154+
name = "Release branch"
155+
negate = false
156+
}
157+
commit_author_email_pattern = {
158+
operator = "contains"
159+
pattern = "gmail.com"
160+
name = "Gmail email"
161+
negate = true
162+
}
163+
commit_message_pattern = {
164+
operator = "ends_with"
165+
pattern = "test"
166+
name = "Test message"
167+
negate = false
168+
}
169+
committer_email_pattern = {
170+
operator = "contains"
171+
pattern = "[email protected]"
172+
name = "Test committer email"
173+
negate = false
174+
}
175+
creation = true
176+
deletion = false
177+
non_fast_forward = true
178+
pull_request = {
179+
dismiss_stale_reviews_on_push = true
180+
require_code_owner_review = true
181+
require_last_push_approval = true
182+
required_approving_review_count = 1
183+
required_review_thread_resolution = true
184+
}
185+
required_deployments = {
186+
required_deployment_environments = [
187+
"staging",
188+
"production"
189+
]
190+
}
191+
required_status_checks = {
192+
required_check = [
193+
{
194+
context = "test"
195+
}
196+
]
197+
strict_required_status_checks_policy = true
198+
do_not_enforce_on_create = true
199+
}
200+
}
201+
}
202+
}

0 commit comments

Comments
 (0)