Question: How can I make a package "disappear" from Github Package Registry?
Background:
Steps so far:
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ACCESS_TOKEN" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"PACKAGE_ID==\"}) { success }}"}' \
https://api.github.com/graphql
curl -X POST \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer ACCESS_TOKEN" \
-d "query {
organization(login: "ORGANIZATION_ACCOUNT") {
registryPackages {
edges {
node {
name
id
}
}
}
}
}" \
https://api.github.com/graphql
# The API returns:
{
"message": "Problems parsing JSON",
"documentation_url": "https://developer.github.com/v4"
}
# See query above - the API returns via the Explorer:
{
"errors": [
{
"type": "INSUFFICIENT_SCOPES",
"locations": [
{
"line": 6,
"column": 11
}
],
"message": "Your token has not been granted the required scopes to execute this query. The 'name' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: ['read:gpg_key', 'read:org', 'read:public_key', 'read:repo_hook', 'repo', 'user'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens."
},
{
"type": "INSUFFICIENT_SCOPES",
"locations": [
{
"line": 7,
"column": 11
}
],
"message": "Your token has not been granted the required scopes to execute this query. The 'id' field requires one of the following scopes: ['read:packages'], but your token has only been granted the: ['read:gpg_key', 'read:org', 'read:public_key', 'read:repo_hook', 'repo', 'user'] scopes. Please modify your token's scopes at: https://github.com/settings/tokens."
}
]
}
Desired Solution
Update1: It's about packages published to a public repository.
Removing a package from a public registry is not allowed, however you can remove a version of a package from a private registry as mentioned in GitHub docs:
Now it is available to delete on GitHub directly:
- On GitHub, navigate to the main page of the repository.
- To the right of the list of files, click Packages.
- Click the name of the package that you want to delete.
- On the right, use the Edit package drop-down and select "Manage versions".
- To the right of the version you want to delete, click Delete.
- To confirm deletion, type the package name and click I understand the consequences, delete this version.
GraphQL was the only method for this purpose in the past:
$ curl -X POST https://api.github.com/graphql \
-H "Accept: application/vnd.github.package-deletes-preview+json" \
-H "Authorization: bearer <github_token>" \
-d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"MDE0OlBhY2thZ2VWZXJzaW9uMzc5MTE0kFcA\"}) { success }}"}'
Version id of GitHub packages can be listed as follows:
$ curl -sL -X POST https://api.github.com/graphql \
-H "Authorization: bearer <github_token>" \
-d '{"query":"query{repository(owner:\"<repo_owner>\",name:\"<repo_name>\"){packages(first:10){nodes{packageType,name,id,versions(first:10){nodes{id,version,readme}}}}}}"}' | jq .
Update the parameters below with yours:
<github_token>
<repo_owner>
<repo_name>
It returns as follows:
{
"data": {
"repository": {
"registryPackages": {
"nodes": [
{
"packageType": "DOCKER",
"registryPackageType": "docker",
"name": "demo_image_1",
"nameWithOwner": "aki***/demo_image_1",
"id": "MDc6UGFja2FnZTYzNjg3AkFc",
"versions": {
"nodes": [
{
"id": "MDE0OlBhY2thZ2VWZXJzaW9uMzc5MTE0kFcA",
"version": "0.1a",
"readme": null
},
{
"id": "MDE0OlBhY2thZ2VWZXJzaW9uMzYzNTY2FcAk",
"version": "0.1",
"readme": null
},
{
"id": "MDE0OlBhY2thZ2VWZXJzaW9uMzYzNTY0cAkF",
"version": "docker-base-layer",
"readme": null
}
]
}
},
]
}
}
}
Package versions of a private can be delete by the maintainer:
Go to your repositories' packages https://github.com/orgs/YOUR_ACCOUNT/packages?repo_name=YOUR_REPO
Select one package https://github.com/YOUR_ACCOUNT/YOUR_REPO/packages/PACKAGE_ID
Show all versions of that package https://github.com/cyface-de/backend/packages/81398/versions
Use the DELETE
button to delete this private package
Package versions of a public repository cannot be deleted by the maintainer, i.e.:
The Github support needs to be contacted to have a package or version removed.
Workaround: make your repository temporarily private for the deletion:
Repository Settings
> Danger Zone
> Make private
Repository Settings
> Danger Zone
> Make public
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With