Skip to content

Commit 7d5f11b

Browse files
committed
Use two parameters to be more consistent with other scripts
1 parent 050b34e commit 7d5f11b

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

gh-cli/delete-repository-webhooks.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
#!/bin/bash
22

3-
if [ $# -ne 1 ]; then
4-
echo "Usage: $0 <repo>"
5-
echo "repo in the format owner/repo"
3+
if [ $# -ne 2 ]; then
4+
echo "Usage: $0 <owner> <repo>"
65
exit 1
76
fi
87

9-
repo=$1
10-
11-
# validate if repo is in format owner/repo
12-
if [[ ! $repo =~ ^[[:alnum:]_-]+/[[:alnum:]_-]+$ ]]; then
13-
echo "ERROR: invalid repo format. Expected owner/repo"
14-
exit 1
15-
fi
8+
owner=$1
9+
repo=$2
1610

1711
# iterate on all repo webhooks and delete them
18-
gh api -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$repo/hooks" --jq '.[].id' | while read -r id; do
12+
gh api -H "X-GitHub-Api-Version: 2022-11-28" "/repos/$owner/$repo/hooks" --jq '.[].id' | while read -r id; do
1913
echo "deleting webhook $id"
2014
gh api -X DELETE "repos/$repo/hooks/$id"
2115
done

0 commit comments

Comments
 (0)