Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit 8097c76

Browse files
committed
fix: enable/disable branch protection
1 parent 394d69a commit 8097c76

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/release.yml

+40
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,22 @@ jobs:
7474
else
7575
echo "No change in package.json, not regenerating third-party notices"
7676
fi
77+
- name: Temporarily disable branch protection
78+
id: disable-branch-protection
79+
uses: actions/github-script@v1
80+
with:
81+
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
82+
previews: luke-cage-preview
83+
script: |
84+
const result = await github.repos.updateBranchProtection({
85+
owner: context.repo.owner,
86+
repo: context.repo.repo,
87+
branch: 'develop',
88+
restrictions: null,
89+
enforce_admins: null,
90+
required_pull_request_reviews: null
91+
})
92+
console.log("Result:", result)
7793
7894
- name: Push Commit
7995
if: steps.generate-notices.outputs.commit == 'true'
@@ -82,6 +98,30 @@ jobs:
8298
github_token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
8399
branch: develop
84100

101+
- name: Re-enable branch protection
102+
id: enable-branch-protection
103+
if: always()
104+
uses: actions/github-script@v1
105+
with:
106+
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
107+
previews: luke-cage-preview
108+
script: |
109+
const result = await github.repos.updateBranchProtection({
110+
owner: context.repo.owner,
111+
repo: context.repo.repo,
112+
branch: 'develop',
113+
restrictions: {
114+
users: [],
115+
teams: ['developer-enablement']
116+
},
117+
enforce_admins: true,
118+
required_pull_request_reviews: {
119+
dismiss_stale_reviews: true,
120+
required_approving_review_count: 1
121+
}
122+
})
123+
console.log("Result:", result)
124+
85125
job-generate-release:
86126
runs-on: ubuntu-latest
87127
needs: [job-generate-third-party-notices]

0 commit comments

Comments
 (0)