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

Commit 8dfcc93

Browse files
committed
fix: add branch protection handling in workflows
1 parent 5dbf35f commit 8dfcc93

File tree

1 file changed

+45
-5
lines changed

1 file changed

+45
-5
lines changed

.github/workflows/project-stats.yml

+45-5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,24 @@ jobs:
2727
github-token: ${{ secrets.NEWRELIC_BOT_TOKEN }} # must have push access to repos for stats queries to work
2828
project-stats: true
2929

30+
- name: Temporarily disable branch protection
31+
id: disable-branch-protection
32+
uses: actions/github-script@v1
33+
with:
34+
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
35+
previews: luke-cage-preview
36+
script: |
37+
const result = await github.repos.updateBranchProtection({
38+
owner: context.repo.owner,
39+
repo: context.repo.repo,
40+
branch: 'develop',
41+
required_status_checks: null,
42+
restrictions: null,
43+
enforce_admins: null,
44+
required_pull_request_reviews: null
45+
})
46+
console.log("Result:", result)
47+
3048
- name: Commit data files
3149
run: |
3250
git config --local user.email "${{ env.THIRD_PARTY_GIT_AUTHOR_EMAIL }}"
@@ -49,11 +67,33 @@ jobs:
4967
git cherry-pick $CHERRYCOMMIT
5068
git push origin main
5169
52-
# - name: Push Commit
53-
# uses: ad-m/[email protected]
54-
# with:
55-
# github_token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
56-
# branch: ${{ github.ref }} #pushes to the branch that kicked off the job
70+
- name: Re-enable branch protection
71+
id: enable-branch-protection
72+
if: always()
73+
uses: actions/github-script@v1
74+
with:
75+
github-token: ${{ secrets.OPENSOURCE_BOT_TOKEN }}
76+
previews: luke-cage-preview
77+
script: |
78+
const result = await github.repos.updateBranchProtection({
79+
owner: context.repo.owner,
80+
repo: context.repo.repo,
81+
branch: 'develop',
82+
required_status_checks: {
83+
strict: false,
84+
contexts: ['Gatsby Build']
85+
},
86+
restrictions: {
87+
users: [],
88+
teams: []
89+
},
90+
enforce_admins: true,
91+
required_pull_request_reviews: {
92+
dismiss_stale_reviews: true,
93+
required_approving_review_count: 1
94+
}
95+
})
96+
console.log("Result:", result)
5797
5898
job-checkout-and-build:
5999
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)