Skip to content

Commit

Permalink
Update add-checks.yml
Browse files Browse the repository at this point in the history
Signed-off-by: Rakshith B <[email protected]>
  • Loading branch information
Rakshithb1 authored Jan 12, 2024
1 parent 4828e13 commit 9ed5b1c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/add-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,29 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Add branch protection rule
run: |
TOKEN=$GITHUB_TOKEN
REPO_OWNER=${{ github.repository_owner }}
REPO_NAME=${{ github.event.repository.name }}
BRANCH_NAME=${{ github.event.ref }}
# Create a branch protection rule
curl -X PUT \
-H "Authorization: Bearer $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/branches/$BRANCH_NAME/protection \
-d '{
"required_status_checks": {
"contexts": ["your-check-name"]
},
"enforce_admins": true,
"required_pull_request_reviews": null,
"restrictions": null
}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Add branch protection rule
run: |
Expand Down

0 comments on commit 9ed5b1c

Please sign in to comment.