Skip to content

Commit 75dc3fa

Browse files
chore: branch protections in contributors.yml
1 parent f9b7279 commit 75dc3fa

File tree

1 file changed

+57
-1
lines changed

1 file changed

+57
-1
lines changed

.github/workflows/contributors.yml

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,66 @@ jobs:
66
with:
77
fetch-depth: 0
88
- uses: ./.github/actions/prepare
9-
- uses: JoshuaKGoldberg/[email protected]
9+
- uses: JoshuaKGoldberg/[email protected]
10+
- name: Delete branch protection on main
11+
uses: actions/[email protected]
12+
with:
13+
github-token: ${{ secrets.ACCESS_TOKEN }}
14+
script: |
15+
try {
16+
await github.request(
17+
`DELETE /repos/JoshuaKGoldberg/template-typescript-node-package/branches/main/protection`,
18+
);
19+
} catch (error) {
20+
if (!error.message?.includes?.("Branch not protected")) {
21+
throw error;
22+
}
23+
}
1024
- uses: stefanzweifel/git-auto-commit-action@v4
1125
with:
1226
commit_message: "Fill in all-contributors"
27+
- if: always()
28+
name: Recreate branch protection on main
29+
uses: actions/[email protected]
30+
with:
31+
github-token: ${{ secrets.ACCESS_TOKEN }}
32+
# Note: keep this inline script in sync with script/setup.js!
33+
# Todo: it would be nice to not have two sources of truth...
34+
# https://github.com/JoshuaKGoldberg/template-typescript-node-package/issues/145
35+
script: |
36+
github.request(
37+
`PUT /repos/JoshuaKGoldberg/template-typescript-node-package/branches/main/protection`,
38+
{
39+
allow_deletions: false,
40+
allow_force_pushes: true,
41+
allow_fork_pushes: false,
42+
allow_fork_syncing: true,
43+
block_creations: false,
44+
branch: "main",
45+
enforce_admins: false,
46+
owner: "JoshuaKGoldberg",
47+
repo: "template-typescript-node-package",
48+
required_conversation_resolution: true,
49+
required_linear_history: false,
50+
required_pull_request_reviews: null,
51+
required_status_checks: {
52+
checks: [
53+
{ context: "build" },
54+
{ context: "compliance" },
55+
{ context: "knip" },
56+
{ context: "lint" },
57+
{ context: "markdown" },
58+
{ context: "package" },
59+
{ context: "packages" },
60+
{ context: "prettier" },
61+
{ context: "spelling" },
62+
{ context: "test" },
63+
],
64+
strict: false,
65+
},
66+
restrictions: null,
67+
}
68+
);
1369
1470
name: Contributors
1571

0 commit comments

Comments
 (0)