This answer: "How to perform status checks in github repository?" ..
References the following articles:
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
So, to update a status check, I need to create one (and update it with a status at the same time); as per: https://developer.github.com/v3/repos/statuses/#create-a-status ... Issue a POST
to:
/repos/:owner/:repo/statuses/:sha
However, I am getting a 404 (response.status_code: 404
), whenever I try to post a payload to the endpoint url.
NOTE: I am building the url, using the information from the GitHub web-hook itself i.e.
content['repository']['owner']['login']
content['repository']['name']
content['pull_request']['head']['sha']
JSON Payload:
payload = { "state": "pending", "description": "The build succeeded!", "context": "continuous-integration/audit-compliance"}
Request:
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)
Response:
{'message': 'Not Found', 'documentation_url': 'https://developer.github.com/enterprise/2.18/v3/repos/statuses/#create-a-status'}
With 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
Where am I going wrong?
Can provide additional info on request; TIA.
See that in the example the url has no v3 prefix, the template below shall work for you:
https://api.github.com/repos/ORGNAME/REPONAME/statuses/<SHA>
https://github.com/api/v3/repos///statuses/ .. works fine.
The permission settings for GitHub token were the problem; Github really need to fix their exception handling; 404 it is not!