Skip to content

Instantly share code, notes, and snippets.

@bradymholt
Created November 22, 2019 18:05
Show Gist options
  • Save bradymholt/15d210f3eee4637d3a20ca3f74d9cc6a to your computer and use it in GitHub Desktop.
Save bradymholt/15d210f3eee4637d3a20ca3f74d9cc6a to your computer and use it in GitHub Desktop.
Delete Private GitHub Docker Registry packages
# Find latest version of packages
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer $GITHUB_API_TOKEN" \
-d '{"query":"query { repository(owner:\"johndoe\", name:\"myepo\") { registryPackagesForQuery(first:10) { edges { node { latestVersion { id } } } } } }"}' \
https://api.github.com/graphql
# Example output from above command
# {"data":{"repository":{"registryPackagesForQuery":{"edges":[{"node":{"latestVersion":{"id":"MDE01234523233"}}}]}}}}
# Delete version
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer $GITHUB_API_TOKEN" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"MDE01234523233\"}) { success }}"}' \
https://api.github.com/graphql
# Keep deleting versions until all have been removed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment