Skip to content

Commit 41bb6c1

Browse files
committed
feat: Add GitHub branch protection JSON configurations
- Add main-branch-protection.json for simple main branch protection - Add github-repository-rules.json for comprehensive repository rules - Add github-branch-protection.json for basic branch protection - Provide multiple JSON options for different GitHub features - Ready to upload to GitHub repository settings
1 parent 884f157 commit 41bb6c1

File tree

3 files changed

+241
-0
lines changed

3 files changed

+241
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "EJBCA Automated Lab Repository Rules",
3+
"target": "branch",
4+
"enforcement": "active",
5+
"conditions": {
6+
"ref_name": {
7+
"include": ["main", "develop"]
8+
}
9+
},
10+
"parameters": {
11+
"required_status_checks": {
12+
"strict": true,
13+
"contexts": [
14+
"branch-protection-check",
15+
"terraform-validate",
16+
"security-scanning",
17+
"kubernetes-deploy",
18+
"ansible-lint"
19+
]
20+
},
21+
"dismiss_stale_reviews_on_push": true,
22+
"require_code_owner_reviews": true,
23+
"required_approving_review_count": 2,
24+
"require_last_push_approval": true,
25+
"required_linear_history": true,
26+
"allow_force_pushes": false,
27+
"allow_deletions": false,
28+
"block_creations": false,
29+
"required_conversation_resolution": true,
30+
"require_signed_commits": true,
31+
"lock_branch": false,
32+
"allow_fork_syncing": true
33+
}
34+
}
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
{
2+
"rules": [
3+
{
4+
"name": "Main Branch Protection",
5+
"target": "branch",
6+
"enforcement": "active",
7+
"conditions": {
8+
"ref_name": {
9+
"include": ["main"]
10+
}
11+
},
12+
"parameters": {
13+
"required_status_checks": {
14+
"strict": true,
15+
"contexts": [
16+
"branch-protection-check",
17+
"terraform-validate",
18+
"security-scanning",
19+
"kubernetes-deploy",
20+
"ansible-lint"
21+
]
22+
},
23+
"dismiss_stale_reviews_on_push": true,
24+
"require_code_owner_reviews": true,
25+
"required_approving_review_count": 2,
26+
"require_last_push_approval": true,
27+
"required_linear_history": true,
28+
"allow_force_pushes": false,
29+
"allow_deletions": false,
30+
"block_creations": false,
31+
"required_conversation_resolution": true,
32+
"require_signed_commits": true,
33+
"lock_branch": false,
34+
"allow_fork_syncing": true
35+
}
36+
},
37+
{
38+
"name": "Develop Branch Protection",
39+
"target": "branch",
40+
"enforcement": "active",
41+
"conditions": {
42+
"ref_name": {
43+
"include": ["develop"]
44+
}
45+
},
46+
"parameters": {
47+
"required_status_checks": {
48+
"strict": true,
49+
"contexts": [
50+
"branch-protection-check",
51+
"terraform-validate",
52+
"security-scanning"
53+
]
54+
},
55+
"dismiss_stale_reviews_on_push": true,
56+
"require_code_owner_reviews": false,
57+
"required_approving_review_count": 1,
58+
"require_last_push_approval": false,
59+
"required_linear_history": false,
60+
"allow_force_pushes": false,
61+
"allow_deletions": true,
62+
"block_creations": false,
63+
"required_conversation_resolution": true,
64+
"require_signed_commits": false,
65+
"lock_branch": false,
66+
"allow_fork_syncing": true
67+
}
68+
},
69+
{
70+
"name": "Feature Branch Rules",
71+
"target": "branch",
72+
"enforcement": "active",
73+
"conditions": {
74+
"ref_name": {
75+
"include": ["feat/*", "feature/*", "bugfix/*", "hotfix/*"]
76+
}
77+
},
78+
"parameters": {
79+
"required_status_checks": {
80+
"strict": true,
81+
"contexts": [
82+
"branch-protection-check",
83+
"terraform-validate"
84+
]
85+
},
86+
"dismiss_stale_reviews_on_push": true,
87+
"require_code_owner_reviews": false,
88+
"required_approving_review_count": 1,
89+
"require_last_push_approval": false,
90+
"required_linear_history": false,
91+
"allow_force_pushes": false,
92+
"allow_deletions": true,
93+
"block_creations": false,
94+
"required_conversation_resolution": true,
95+
"require_signed_commits": false,
96+
"lock_branch": false,
97+
"allow_fork_syncing": true
98+
}
99+
},
100+
{
101+
"name": "Pull Request Rules",
102+
"target": "pull_request",
103+
"enforcement": "active",
104+
"conditions": {
105+
"ref_name": {
106+
"include": ["main", "develop"]
107+
}
108+
},
109+
"parameters": {
110+
"required_approving_review_count": 2,
111+
"dismiss_stale_reviews_on_push": true,
112+
"require_code_owner_reviews": true,
113+
"require_last_push_approval": true,
114+
"required_linear_history": true,
115+
"required_conversation_resolution": true
116+
}
117+
},
118+
{
119+
"name": "Commit Message Rules",
120+
"target": "tag",
121+
"enforcement": "active",
122+
"conditions": {},
123+
"parameters": {
124+
"pattern": "^(feat|fix|docs|style|refactor|test|chore|ci|build|perf|revert)(\\(.+\\))?: .{1,50}",
125+
"operator": "regex"
126+
}
127+
},
128+
{
129+
"name": "Terraform Files Protection",
130+
"target": "path",
131+
"enforcement": "active",
132+
"conditions": {
133+
"ref_name": {
134+
"include": ["main", "develop"]
135+
}
136+
},
137+
"parameters": {
138+
"rules": [
139+
{
140+
"name": "Terraform files require review",
141+
"paths": {
142+
"include": ["terraform/**"]
143+
},
144+
"required_approving_review_count": 2,
145+
"require_code_owner_reviews": true
146+
},
147+
{
148+
"name": "Security-sensitive files",
149+
"paths": {
150+
"include": [
151+
"**/*secret*",
152+
"**/*key*",
153+
"**/*password*",
154+
"**/*credential*",
155+
"**/*token*"
156+
]
157+
},
158+
"required_approving_review_count": 2,
159+
"require_code_owner_reviews": true
160+
},
161+
{
162+
"name": "Documentation changes",
163+
"paths": {
164+
"include": ["docs/**", "*.md"]
165+
},
166+
"required_approving_review_count": 1,
167+
"require_code_owner_reviews": false
168+
}
169+
]
170+
}
171+
}
172+
]
173+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"name": "Main Branch Protection",
3+
"target": "branch",
4+
"enforcement": "active",
5+
"conditions": {
6+
"ref_name": {
7+
"include": ["main"]
8+
}
9+
},
10+
"parameters": {
11+
"required_status_checks": {
12+
"strict": true,
13+
"contexts": [
14+
"branch-protection-check",
15+
"terraform-validate",
16+
"security-scanning",
17+
"kubernetes-deploy",
18+
"ansible-lint"
19+
]
20+
},
21+
"dismiss_stale_reviews_on_push": true,
22+
"require_code_owner_reviews": true,
23+
"required_approving_review_count": 2,
24+
"require_last_push_approval": true,
25+
"required_linear_history": true,
26+
"allow_force_pushes": false,
27+
"allow_deletions": false,
28+
"block_creations": false,
29+
"required_conversation_resolution": true,
30+
"require_signed_commits": true,
31+
"lock_branch": false,
32+
"allow_fork_syncing": true
33+
}
34+
}

0 commit comments

Comments
 (0)