使用 github cli 将外部协作者添加到组织存储库
Add outside collaborator to organization repository using github cli
我正在使用gh-cli
我想将外部协作者添加到我的组织 (my-org
) 中的私有存储库 (my-repo-in-org
)
我可以使用这个显示协作者gh
gh api repos/my-org/myrepo-in-org/collaborators
基于文档 Add a repository collaborator
我尝试使用
添加具有 push
权限的协作者 (collaborator_name
)
gh api repos/my-org/my-repo-in-org/collaborators/collaborator-name -f '{"permission"="push"}'
但是得到:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
gh: Not Found (HTTP 404)
知道我该怎么做吗?
我需要管理多个用户的多个存储库,并希望将其自动化。
当您使用 -f/--raw-field
指定参数时使用的默认 http 方法是 POST
但此调用需要 PUT
方法。您可以使用 -X
或 --method
告诉 gh 指定方法:
gh api repos/{owner}/{repo}/collaborators/{username} -X PUT -f permission='push'
来自documentation :
The default HTTP request method is "GET" normally and "POST" if any
parameters were added. Override the method with '--method'.
在选项列表中:
-X, --method string The HTTP method for the request (default "GET")
我正在使用gh-cli
我想将外部协作者添加到我的组织 (my-org
) 中的私有存储库 (my-repo-in-org
)
我可以使用这个显示协作者gh
gh api repos/my-org/myrepo-in-org/collaborators
基于文档 Add a repository collaborator 我尝试使用
添加具有push
权限的协作者 (collaborator_name
)
gh api repos/my-org/my-repo-in-org/collaborators/collaborator-name -f '{"permission"="push"}'
但是得到:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
gh: Not Found (HTTP 404)
知道我该怎么做吗?
我需要管理多个用户的多个存储库,并希望将其自动化。
当您使用 -f/--raw-field
指定参数时使用的默认 http 方法是 POST
但此调用需要 PUT
方法。您可以使用 -X
或 --method
告诉 gh 指定方法:
gh api repos/{owner}/{repo}/collaborators/{username} -X PUT -f permission='push'
来自documentation :
The default HTTP request method is "GET" normally and "POST" if any parameters were added. Override the method with '--method'.
在选项列表中:
-X, --method string The HTTP method for the request (default "GET")