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:
- Set the repo as private (blowing away any stars or watchers of that repo in the process)
- Manually get the list of versions using
curl
and some stupid GraphQL (what happened to REST? Man, I must be getting old...) - Manually delete it with another GraphQL query
- Set the repo as public again
- 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.