Skip to content

Instantly share code, notes, and snippets.

@zulhfreelancer
Last active October 11, 2022 13:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zulhfreelancer/a32bee3d37ffb90c93e00bf4b7fe26cf to your computer and use it in GitHub Desktop.
Save zulhfreelancer/a32bee3d37ffb90c93e00bf4b7fe26cf to your computer and use it in GitHub Desktop.
Delete all GitHub Actions runs
# ===========================================================================
# Requirements
# * gh CLI: https://cli.github.com (make sure you are logged-in to the CLI)
# * jq CLI: https://stedolan.github.io/jq
# ===========================================================================
export TARGET_USER=github_user_or_org
export TARGET_REPO=github_repo_name
while :
do
SIZE=$(gh api repos/$TARGET_USER/$TARGET_REPO/actions/runs | jq -r .total_count)
echo "Found: $SIZE"
if [[ $SIZE -eq 0 ]]
then
echo "All done"
break
fi
gh api repos/$TARGET_USER/$TARGET_REPO/actions/runs | \
jq -r '.workflow_runs[] | .id' | \
xargs -n1 -I % gh api --silent repos/$TARGET_USER/$TARGET_REPO/actions/runs/% -X DELETE
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment