在一天结束时,我正试图实现从这里链接的解决方案:重用Github Actions自托管运行器在多个存储库。但是教程会引导你在UI中设置GitHub应用程序,我试图通过API来实现。
背景:
-
创建新的GitHub应用程序"(不是"OAuth应用")在GitHub企业v3.0(即将迁移到v3.1)。
-
试图通过创建一个"应用程序清单"来完全通过API而不是UI来实现。(https://docs.github.com/en/enterprise-server@3.0/开发/应用程序/building-github-apps/creating-a-github-app-from-a-manifest)。
-
我读过的关于docs.github.com权限的所有内容最终指向https://docs.github.com/en/enterprise-server@3.0/rest/reference/permissions-required-github -apps,其中不包括可以与API一起使用的特定值。
-
在GHE实例上,在URL上有一个大的权限列表,使用这种模式:
https://{HOSTNAME}/organizations/{ORG}/settings/apps/{APP}/permissions
-
我正在尝试设置的特定权限说:
自托管的跑步者
查看和管理组织可用的Actions自托管运行程序。
Access: Read &写 -
在文档(https://docs.github.com/en/enterprise-server@3.0/developers/apps/building-github-apps/creating-a-github-app-from-a-manifest#github-app-manifest-parameters)中有一个参数叫
default_permissions
。这个权限使用的标识符(键)是什么,这里的值是
write
我试过:
Self-hosted runners
文件- 猜测
self-hosted runners
- 猜测
self-hosted_runners
- 猜测
self_hosted_runners
- 猜测
selfhosted_runners
- 猜测
runners
…,但最终,这里可以使用的实际值是(据我所知,经过几个小时的挖掘和猜测)未记录的。
actions:read
和checks:read
似乎可以工作。和没有文档,但我能够通过查看url,做出有根据的猜测和测试来弄清楚它。 -
我可以在互联网上找到的所有教程,包括docs.github.com上的教程,都可以通过UI引导您创建新的GitHub应用程序。我非常明确地尝试通过API来做到这一点。
提示吗?我错过什么了吗?这在GHE中还没有提供吗?
这是我的应用程序清单,编辑。
{
"public": true,
"name": "My app",
"description": "My app's description.",
"url": "https://github.example.com/my-org/my-repo",
"redirect_url": "http://localhost:9876/register/redirect",
"default_events": [],
"default_permissions": {
"actions": "read",
"checks": "read",
"runners": "write"
},
"hook_attributes": {
"url": "",
"active": false
}
}
对于"runners": "write"
行,我收到的错误消息说:
无效的GitHub应用程序配置
配置似乎不是有效的GitHub应用程序清单。
x错误默认权限记录资源不包含在列表中
没有"runners": "write"
行,提交成功。
GitHub团队终于更新了文档。我要找的权限是organization_self_hosted_runners
。