Created
November 22, 2019 18:05
-
-
Save bradymholt/15d210f3eee4637d3a20ca3f74d9cc6a to your computer and use it in GitHub Desktop.
Delete Private GitHub Docker Registry packages
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
# 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