问题
I have read the instructions on how to delete a version here: https://help.github.com/en/github/managing-packages-with-github-packages/deleting-a-package
When I tried to use the curl, it just gives me this error:
{
  "message": "Problems parsing JSON",
  "documentation_url": "https://developer.github.com/v4"
}
This is my curl:
curl -X POST -H "Accept: application/vnd.github.package-deletes-preview+json" -H "Authorization: bearer PERSONALACCESSTOKEN" -d '{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"1.0.0\"}) { success }}"}' https://api.github.com/graphql
Am I missing something? How can I properly authenticate myself?
回答1:
You are passing a value of 1.0.0 for packageVersionId here:
'{"query":"mutation { deletePackageVersion(input:{packageVersionId:\"1.0.0\"}) { success }}"}'
packageVersionId is the id of package layers.
You can query the GitHub packages with a command 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>\"){registryPackages(first:10){nodes{packageType,registryPackageType,name,nameWithOwner,id,versions(first:10){nodes{id,version,readme}}}}}}"}' | jq .
(Make sure to update <github_token>, <repo_owner> and <repo_name>)
For example packageVersionId becomes MDE0OlBhY2thZ2VWZXJzaW9uMzc5MTE0kFcA for the version of 0.1a on a following returned output of above command:
***
  "registryPackages": {
    "nodes": [
      {
        "packageType": "DOCKER",
        "registryPackageType": "docker",
        "name": "demo_image",
        "nameWithOwner": "aki***/demo_image",
        "id": "MDc6UGFja2FnZTYzNjg3AkFc",
        "versions": {
          "nodes": [
            {
              "id": "MDE0OlBhY2thZ2VWZXJzaW9uMzc5MTE0kFcA",
              "version": "0.1a",
              "readme": null
            },
***
    来源:https://stackoverflow.com/questions/59559176/github-package-registry-how-to-delete-a-version