Skip to content

Commit

Permalink
Update newcheck.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 16, 2024
1 parent 97e6ae0 commit 5dbb828
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions .github/workflows/newcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
api_method:
description: 'Provide API method (ADD, GET, DELETE)'
description: 'Provide API method (Add, Get, Delete)'
required: true
default: ''
type: string
Expand All @@ -18,17 +18,8 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Get branch protection rule
run: |
tail -n +2 .github/workflows/check.csv | while IFS=, read -r REPO_NAME BRANCH_NAME CHECKS; do
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $G_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_NAME/branches/$BRANCH_NAME/protection/required_status_checks/contexts
done
- name: Add branch protection rule
if: "${{ contains(github.event.inputs.api_method, 'ADD') }}"
run: |
tail -n +2 .github/workflows/check.csv | while IFS=, read -r REPO_NAME BRANCH_NAME CHECKS; do
curl -L \
Expand All @@ -39,3 +30,27 @@ jobs:
"https://api.github.com/repos/$REPO_NAME/branches/$BRANCH_NAME/protection/required_status_checks/contexts" \
-d "{\"contexts\":[\"$CHECKS\"]}"
done
- name: Get branch protection rule
if: "${{ contains(github.event.inputs.api_method, 'Delete') }}"
run: |
tail -n +2 .github/workflows/check.csv | while IFS=, read -r REPO_NAME BRANCH_NAME CHECKS; do
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/OWNER/REPO/branches/BRANCH/protection/required_status_checks/contexts \
-d '{"contexts":["continuous-integration/jenkins"]}'
done
- name: Get branch protection rule
if: "${{ contains(github.event.inputs.api_method, 'Get') || false }}"
run: |
tail -n +2 .github/workflows/check.csv | while IFS=, read -r REPO_NAME BRANCH_NAME CHECKS; do
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $G_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_NAME/branches/$BRANCH_NAME/protection/required_status_checks/contexts
done

0 comments on commit 5dbb828

Please sign in to comment.