Skip to content

Instantly share code, notes, and snippets.

@JamesHagerman
Created December 8, 2019 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesHagerman/3590fbcbc99d3b55bd16079b87d5f1aa to your computer and use it in GitHub Desktop.
Save JamesHagerman/3590fbcbc99d3b55bd16079b87d5f1aa to your computer and use it in GitHub Desktop.
GitHub has a dangerous and broken docker registry implementation...

GitHub blocks deleting docker tags of public repos

GitHub has a dangerous and broken docker registry implementation...

They block the ability to overwrite existing docker versions. This breaks the pattern of having a latest image that can always be the most up to date.

So to work around this, we have to:

  1. Set the repo as private (blowing away any stars or watchers of that repo in the process)
  2. Manually get the list of versions using curl and some stupid GraphQL (what happened to REST? Man, I must be getting old...)
  3. Manually delete it with another GraphQL query
  4. Set the repo as public again
  5. Push a new version

What absolute idiocy. At least make latest overwriteable...

List the versions:

curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: bearer GITHUB_TOKEN" \
-d '{"query":"{ user(login: \"GITHUB_USERNAME\") { registryPackagesForQuery(first: 10, query:\"is:private\") { totalCount nodes { nameWithOwner versions(first: 10) { nodes { id version } } } } }}"}' \
https://api.github.com/graphql

Delete the version based on its id:

curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer GITHUB_TOKEN" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"MDE0OlBhY2thZ2VWZXJzaW9uNDIxMjI4\"}) { success }}"}' \
https://api.github.com/graphql
{"data":{"deletePackageVersion":{"success":true}}}

Then you can re-push to the same tag again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment