-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: 🧹 add script for deleting old jobs
- Loading branch information
Ashley
committed
Nov 17, 2023
1 parent
dd8a8ec
commit ed1cee8
Showing
1 changed file
with
29 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,29 @@ | ||
#!/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) | ||
|
||
# Set the workflow ID | ||
WORKFLOW_ID="39941505" | ||
|
||
# Get all the runs for the workflow ID | ||
WORKFLOW_RUNS_URL="https://api.github.com/repos/$USERNAME/$REPO/actions/workflows/$WORKFLOW_ID/runs?per_page=1000" | ||
WORKFLOW_RUNS=$(curl -s -H "Authorization: token $TOKEN" $WORKFLOW_RUNS_URL) | ||
|
||
# List all the run IDs | ||
RUN_IDS=$(echo $WORKFLOW_RUNS | jq -r '.workflow_runs[].id') | ||
|
||
I=0 | ||
|
||
for run_id in $RUN_IDS; do | ||
echo "$I: Deleting run with ID $run_id" | ||
curl -X DELETE -H "Authorization: token $TOKEN" \ | ||
"https://api.github.com/repos/$USERNAME/$REPO/actions/runs/$run_id" | ||
I=$((I+1)) | ||
done |