Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions list-repo-webhooks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#list-repository-webhooks
# GET /repos/{owner}/{repo}/hooks

## This shell script is deprecated from the power


curl --silent ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
Expand Down
12 changes: 12 additions & 0 deletions list-repository-webhooks.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/repos/webhooks?apiVersion=2022-11-28#list-repository-webhooks
# GET /repos/{owner}/{repo}/hooks


curl --silent ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/hooks"

30 changes: 30 additions & 0 deletions update-a-repository-webhook.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/enterprise-cloud@latest/rest/repos/webhooks?apiVersion=2022-11-28#update-a-repository-webhook
# PATCH /repos/{owner}/{repo}/hooks/{hook_id}


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
hook_id=$(./list-repository-webhooks.sh | jq '[.[].id] | max')
else
hook_id=$1
fi

active=true

json_file=tmp/update-a-repository-webhook.json
jq -n \
--arg active "${active}" \
'{
active: $active | test("true"),
}' > ${json_file}


curl ${curl_custom_flags} \
-H "X-GitHub-Api-Version: ${github_api_version}" \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/hooks/${hook_id}" --data @${json_file}