这个answer :“如何在 github 存储库中执行状态检查?” ..
引用以下文章:
https://help.github.com/en/github/administering-a-repository/enabling-required-status-checks https://developer.github.com/v3/guides/building-a-ci-server/#working-with-statuses
因此,要更新状态检查,我需要创建一个(并同时更新状态);按照:https://developer.github.com/v3/repos/statuses/#create-a-status ...发出 POST
至:
/repos/:owner/:repo/statuses/:sha
但是,每当我尝试将负载发布到端点 URL 时,我都会收到 404 (response.status_code: 404
)。
注意:我正在使用来自 GitHub web-hook 本身的信息构建 URL,即
content['repository']['owner']['login']
content['repository']['name']
content['pull_request']['head']['sha']
JSON有效负载:
payload = { "state": "pending", "description": "The build succeeded!", "context": "continuous-integration/audit-compliance"}
请求:
headers = {'Content-Type': 'application/json',
'Authorization': "token "+gittokn}
url = https://github.com/api/v3/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA>
response = requests.post(url, headers=headers, json=payload, verify=False)
回应:
{'message': 'Not Found', 'documentation_url': 'https://developer.github.com/enterprise/2.18/v3/repos/statuses/#create-a-status'}
使用 curl :
curl -Is --user USER:PASS https://github.com/api/v3/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA> | head -1
HTTP/1.1 200 OK
curl -Is --user USER:PASS https://api.github.com/repos/<OWNER>/<REPO>/statuses/<PR-HEAD-SHA> | head -1
# no result
我哪里出错了?
可以根据要求提供额外信息; TIA。
最佳答案
请注意,在示例中,网址没有 v3 前缀,下面的模板适合您:
https://api.github.com/repos/ORGNAME/REPONAME/statuses/<SHA>
更新答案
https://github.com/api/v3/repos///状态/ ..工作正常。
GitHub token 的权限设置是问题所在; Github 确实需要修复他们的异常处理;第404章 不是!
关于github-api - Python GitHub "Status Check"POST 未找到错误! (404),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62213068/