Skip to content

Instantly share code, notes, and snippets.

@winstxnhdw
Created April 12, 2023 20:12
Show Gist options
  • Save winstxnhdw/1db67b934de2239adba5e39466b3c18f to your computer and use it in GitHub Desktop.
Save winstxnhdw/1db67b934de2239adba5e39466b3c18f to your computer and use it in GitHub Desktop.
Shell script for removing specified GitHub workflows.
org=USER_NAME
repo=REPO_NAME
workflow_ids=(1 2 3)
for workflow_id in "${workflow_ids[@]}"
do
echo "Listing runs for the workflow ID $workflow_id"
run_ids=( $(gh api repos/$org/$repo/actions/workflows/$workflow_id/runs --paginate | jq '.workflow_runs[].id') )
for run_id in "${run_ids[@]}"
do
echo "Deleting Run ID $run_id"
gh api repos/$org/$repo/actions/runs/$run_id -X DELETE >/dev/null
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment