Skip to content

Instantly share code, notes, and snippets.

@tomcurran
Created January 4, 2023 13:32
Show Gist options
  • Save tomcurran/120bd18bfda9bf027c9405a6572ea226 to your computer and use it in GitHub Desktop.
Save tomcurran/120bd18bfda9bf027c9405a6572ea226 to your computer and use it in GitHub Desktop.
Delete Artifacts in GitHub Repository
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