@@ -18,17 +18,61 @@ jobs:
18
18
- env :
19
19
NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
20
20
run : npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
21
- - name : Temporarily disable "include administrators" branch protection
22
- uses :
benjefferies/[email protected]
21
+ - name : Delete branch protection on main
22
+
23
23
with :
24
- access_token : ${{ secrets.ACCESS_TOKEN }}
25
- branch : ${{ github.event.repository.default_branch }}
24
+ github-token : ${{ secrets.ACCESS_TOKEN }}
25
+ script : |
26
+ try {
27
+ await github.request(
28
+ `DELETE /repos/JoshuaKGoldberg/template-typescript-node-package/branches/main/protection`,
29
+ );
30
+ } catch (error) {
31
+ if (!error.message?.includes?.("Branch not protected")) {
32
+ throw error;
33
+ }
34
+ }
26
35
- env :
27
36
GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
28
37
run : pnpm release-it
29
38
- if : always()
30
- name : Enable "include administrators" branch protection
31
- uses :
benjefferies/[email protected]
39
+ name : Recreate branch protection on main
40
+
32
41
with :
33
- access_token : ${{ secrets.ACCESS_TOKEN }}
34
- branch : ${{ github.event.repository.default_branch }}
42
+ github-token : ${{ secrets.ACCESS_TOKEN }}
43
+ # Note: keep this inline script in sync with script/setup.js!
44
+ # Todo: it would be nice to not have two sources of truth...
45
+ script : |
46
+ github.request(
47
+ `PUT /repos/JoshuaKGoldberg/template-typescript-node-package/branches/main/protection`,
48
+ {
49
+ allow_deletions: false,
50
+ allow_force_pushes: true,
51
+ allow_fork_pushes: false,
52
+ allow_fork_syncing: true,
53
+ block_creations: false,
54
+ branch: "main",
55
+ enforce_admins: false,
56
+ owner: "JoshuaKGoldberg",
57
+ repo: "template-typescript-node-package",
58
+ required_conversation_resolution: true,
59
+ required_linear_history: false,
60
+ required_pull_request_reviews: null,
61
+ required_status_checks: {
62
+ checks: [
63
+ { context: "build" },
64
+ { context: "compliance" },
65
+ { context: "lint" },
66
+ { context: "markdown" },
67
+ { context: "package" },
68
+ { context: "packages" },
69
+ { context: "prettier" },
70
+ { context: "prune" },
71
+ { context: "spelling" },
72
+ { context: "test" },
73
+ ],
74
+ strict: false,
75
+ },
76
+ restrictions: null,
77
+ }
78
+ );
0 commit comments