-
Notifications
You must be signed in to change notification settings - Fork 238
/
Copy pathbranch-protections.nu
42 lines (42 loc) · 1 KB
/
branch-protections.nu
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
#!/usr/bin/env nu
let protections = {
required_status_checks: {
strict: true
checks: [
{
context: 'YOUR CHECK HERE'
app_id: 'YOUR APP ID HERE'
}
]
}
required_pull_request_reviews: {
dismiss_stale_reviews: true
require_code_owner_reviews: true
bypass_pull_request_allowances: {
apps: [
YOUR APP HERE
]
}
}
restrictions: {
users: []
teams: []
apps: [
YOUR APP HERE
]
}
enforce_admins: true
required_linear_history: true
require_conversation_resolution: true
allow_deletions: false
allow_force_pushes: false
}
gh api $"orgs/($env.OWNER)/repos"
|from json
|select name default_branch
|each {|repo|
echo $"Setting branch restrictions for ($repo.name)"
$protections
|to json
|gh api -X PUT $"repos/($env.OWNER)/($repo.name)/branches/($repo.default_branch)/protection" --input -
}