-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 🧼 add release script for deleting old drafts
- Loading branch information
Ashley
committed
Nov 17, 2023
1 parent
2d2e482
commit dd8a8ec
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# Set your GitHub repository details | ||
USERNAME="wizarrrr" | ||
REPO="wizarr" | ||
|
||
# Get your GitHub Personal Access Token | ||
# Make sure it has the "repo" scope | ||
CURRENT_DIR=$(pwd) | ||
TOKEN=$(cat $CURRENT_DIR/scripts/github_token.txt) | ||
|
||
# Fetch all releases (including drafts) using the GitHub API | ||
releases=$(curl -s -H "Authorization: token $TOKEN" "https://api.github.com/repos/$USERNAME/$REPO/releases?per_page=100") | ||
|
||
# Delete all releases that are drafts | ||
for row in $(echo "${releases}" | jq -r '.[] | @base64'); do | ||
_jq() { | ||
echo ${row} | base64 --decode | jq -r ${1} | ||
} | ||
|
||
if [ $(_jq '.draft') == true ]; then | ||
id=$(_jq '.id') | ||
echo "Deleting release with id $id and tag $(_jq '.tag_name')" | ||
curl -X DELETE -H "Authorization: token $TOKEN" "https://api.github.com/repos/$USERNAME/$REPO/releases/$id" | ||
fi | ||
done |