Last active
October 11, 2022 13:01
-
-
Save zulhfreelancer/a32bee3d37ffb90c93e00bf4b7fe26cf to your computer and use it in GitHub Desktop.
Delete all GitHub Actions runs
This file contains hidden or 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
# =========================================================================== | |
# 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