Skip to content

Commit 089b0a3

Browse files
Merge pull request #13 from tspascoal/delete-repo-webhooks
Add delete-repository-webhooks.sh
2 parents b7d32db + 7d5f11b commit 089b0a3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

gh-cli/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,12 @@ May need to run this first in order for the gh cli to be able to have delete rep
156156
gh auth refresh -h github.com -s delete_repo
157157
```
158158

159+
## delete-repository-webhooks.sh
160+
161+
Deletes all webhooks from a repository.
162+
163+
> **Warning** This operation is not reversible.
164+
159165
## download-private-release-artifact.sh
160166

161167
Downloads a release artifact from a private/internal repository. Can either download latest version or specific version, and supports file pattern matching to download one or multiple files. See [docs](https://cli.github.com/manual/gh_release_download) for more info.

gh-cli/delete-repository-webhooks.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
if [ $# -ne 2 ]; then
4+
echo "Usage: $0 <owner> <repo>"
5+
exit 1
6+
fi
7+
8+
owner=$1
9+
repo=$2
10+
11+
# iterate on all repo webhooks and delete them
12+
gh api -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$owner/$repo/hooks" --jq '.[].id' | while read -r id; do
13+
echo "deleting webhook $id"
14+
gh api -X DELETE "repos/$repo/hooks/$id"
15+
done
16+

0 commit comments

Comments
 (0)