Created
January 4, 2023 13:32
-
-
Save tomcurran/120bd18bfda9bf027c9405a6572ea226 to your computer and use it in GitHub Desktop.
Delete Artifacts in GitHub Repository
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
OWNER=$1 | |
REPO=$2 | |
echo "Owner: $OWNER" | |
echo "Repository: $REPO" | |
TOTAL_ARTIFACTS=$(gh api -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/actions/artifacts | jq '.total_count') | |
echo "Total Artifacts: $TOTAL_ARTIFACTS" | |
echo "Deleting artifacts..." | |
gh api --paginate -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/actions/artifacts \ | |
| jq '.artifacts[] | .id' \ | |
| xargs -I %s -- gh api --method DELETE -H "Accept: application/vnd.github+json" /repos/$OWNER/$REPO/actions/artifacts/%s | |
echo "Fin" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment