要获取个人访问令牌:https://github.com/settings/tokens
我有一个私人存储库,我想从中获取发布数据(https://github.com/**user_name**/**repo_name**/releases)。为此目的我应该使用什么范围?
重要提示:我只想对发布数据进行身份验证,而不是对整个私有存储库进行身份验证。
我尝试过的: 这篇文章建议使用Full control of private repositories scope,但我不想授权整个存储库访问,只是授权发布数据。
我在目录的子文件夹中创建了一个自定义拉取请求模板(遵循GitHub Docs).github,例如:
\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 PULL_REQUEST_TEMPLATE\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 custom-template.md\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 PULL_REQUEST_TEMPLATE.md\nRun Code Online (Sandbox Code Playgroud)\n关于带有查询参数的问题和拉取请求的自动化表示您可以在创建拉取请求时将自定义模板名称作为查询参数传递,例如
\n\n\n您可以使用 template 查询参数指定一个模板来自动填充问题或拉取请求正文。
\n
我尝试在创建新的拉取请求"template": "custom-template.md"时添加为查询字符串,但最终得到一个空的拉取请求模板。目录中的默认模板仍然按预期工作,但我不知道如何通过 API 加载自定义模板。.github
我正在使用下面的 GitHub API 调用,该调用从我们的存储库之一返回统计信息。该请求正在返回我需要的数据,但我遇到了此 API 调用的已知限制,即它只会显示存储库的前 100 位贡献者。我们有大约 500 名贡献者,所以我需要知道任何已知的解决方法来获取前 100 名贡献者之外的类似数据?我尝试附加?page=2但我也没有看到该工作。
这是我正在阅读的get-all-contributor-commit-activity的 GitHub 文档,以提出此请求。
获取请求
/repos/{owner}/{repo}/stats/contributors
JSON 返回:
[
{
"total": 10,
"weeks": [
{
"w": 1483833600,
"a": 0,
"d": 0,
"c": 0
}
],
"author": {
"login": "<some user>"
}
}
]
Run Code Online (Sandbox Code Playgroud) 我已经浏览了 Github Rest API v3 和 Github GraphQL API v4,但我无法找到资源/端点来检查 dependentabot 是否通过 API 启用?我已经阅读了大量文档,但找不到任何有用的内容。有人可以指出我正确的文档或告诉我要使用哪个资源吗?谢谢!
我想在没有工具的情况下在 GitHub 存储库上创建(推送)新文件git(因为该git工具在我的主机上不可用PHP)。所以我做了一些研究,发现了GitHub REST API。
我尝试使用curl个人访问令牌来上传或修改我的存储库上的文件。这是我找到的 shell 代码,并进行了curl如下更改:
curl -i https://api.github.com/repos/username/repo/newFile.txt -X PUT
\ -H 'Authorization: token xxxxxxxxxxxxxxxxxxxx' -d "{\"path\": \"newFile.txt\",
\ \"message\": \"update\", \"content\": \"$(openssl base64 -A -in newFile.txt)\", \"branch\":
\"master\",
\ \"sha\": $(curl -X GET https://api.github.com/repos/username/repo/newFile.txt | jq .sha)}"
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
HTTP/1.1 404 未找到
服务器:GitHub.com
我该如何解决这个问题?
PS 即使push file by emailGitHub 或 (GitLab) 上有服务,这也可以帮助通过电子邮件在我的存储库上创建文件。
我正在尝试从私有存储库中的版本下载单个添加的资产,但我得到的只是 404 响应。资产的下载网址是https://github.com/<user>/<repo>/releases/download/20211022/file.json
我尝试了几种不同的方法来指定用户名和私有访问令牌,但都给出了相同的结果。当我使用访问令牌访问 api.github.com 时,它似乎可以工作。
我在curl中尝试过以下格式
curl -i -u <user>:<token> <url>
curl -i "https://<user>:<token>@github.com/ ...."
curl -i -H "Authorization: token <token>" <url>
Run Code Online (Sandbox Code Playgroud)
我可以从发行版下载源代码 (zip),但这有一个不同的 url:https://github.com/<user>/<repo>/archive/refs/tags/20211022.zip
我究竟做错了什么?
根据 API 文档https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
我们可以使用 CURL 来批准拉取请求,即
curl -s -H "Authorization: token ghp_TOKEN" \
-X POST -d '{"event": "APPROVE"}' \
"https://api.github.com/repos/{owner}/{repo}/pulls/{pull_number}/reviews"
Run Code Online (Sandbox Code Playgroud)
但我收到此错误:
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest"
}
Run Code Online (Sandbox Code Playgroud)
尽管如此,CURL 对于其他 API 来说工作得很好,例如:
curl -s -H "Authorization: token ghp_TOKEN" \
-X POST -d '{"body": "some message"}' \
"https://api.github.com/repos/{owner}/{repo}/issues/{pull_number}/reviews"
Run Code Online (Sandbox Code Playgroud)
我已尽一切努力使这项工作成功。有人可以帮我解决这个问题吗?
GitHub 允许创建PR 模板。除了拉取请求审查之外,是否可以做同样的事情?
例如,添加审核清单,如下所示:
- [] Have all the GitHub checks passed?
- [] Is there any redundant code?
- [] Could any optimization be applied?
Run Code Online (Sandbox Code Playgroud) 如何将多个查询批处理到GitHub的GraphQL API的单个请求中?
例如,如何将这两个查询批处理为单个请求并接收单个响应?这种技术可以用于更多的查询(例如200)吗?
{
repositoryOwner(login:"rails") {
repository(name:"rails") {
description
homepageURL
}
}
}
{
repositoryOwner(login:"github") {
repository(name:"graphql-client") {
description
homepageURL
}
}
}
Run Code Online (Sandbox Code Playgroud)
(GitHub GraphQL API可以通过https://developer.github.com/early-access/graphql/explorer/进行实验)
github-api ×10
github ×6
python ×2
automation ×1
curl ×1
git ×1
github-pages ×1
gitlab-api ×1
graphql ×1
pull-request ×1
python-3.x ×1
rest ×1