hb0*_*hb0 13 github-package-registry
问题:如何让一个包从 Github 包注册表中“消失”?
背景:
到目前为止的步骤:
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
Run Code Online (Sandbox Code Playgroud)
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"
}
Run Code Online (Sandbox Code Playgroud)
# 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."
}
]
}
Run Code Online (Sandbox Code Playgroud)
所需的解决方案
更新 1:它是关于发布到公共存储库的包。
Aki*_*kif 16
不允许从公共注册表中删除包,但是您可以从GitHub 文档中提到的私有注册表中删除包的版本:
现在可以直接在 GitHub 上删除:
- 在 GitHub 上,导航到存储库的主页。
- 在文件列表的右侧,单击包。
- 单击要删除的包的名称。
- 在右侧,使用“编辑包”下拉菜单并选择“管理版本”。
- 在要删除的版本右侧,单击删除。
- 要确认删除,请输入包名称并单击我了解后果,删除此版本。
GraphQL 是过去用于此目的的唯一方法:
$ 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 }}"}'
Run Code Online (Sandbox Code Playgroud)
GitHub 包的版本号可以列举如下:
$ 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 .
Run Code Online (Sandbox Code Playgroud)
使用您的参数更新以下参数:
<github_token><repo_owner><repo_name>它返回如下:
{
"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
}
]
}
},
]
}
}
}
Run Code Online (Sandbox Code Playgroud)
hb0*_*hb0 11
维护者可以删除私有的包版本:
维护者不能删除公共存储库的包版本,即:
需要联系 Github 支持以删除包或版本。
解决方法:将您的存储库临时设为私有以进行删除:
Repository Settings> Danger Zone>Make privateRepository Settings> Danger Zone>Make public小智 6
我找到了如何删除包的解决方案。
| 归档时间: |
|
| 查看次数: |
6227 次 |
| 最近记录: |