From ed1cee8e4b7ebd65e9546b668676c3cb9b2ee641 Mon Sep 17 00:00:00 2001 From: Ashley Date: Fri, 17 Nov 2023 16:00:04 +0000 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A7=B9=20add=20script=20for=20de?= =?UTF-8?q?leting=20old=20jobs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/delete-old-workflows.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 scripts/delete-old-workflows.sh diff --git a/scripts/delete-old-workflows.sh b/scripts/delete-old-workflows.sh new file mode 100755 index 000000000..24ca362ea --- /dev/null +++ b/scripts/delete-old-workflows.sh @@ -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 \ No newline at end of file