1

I want to set a commit status in my personal repo. I'm following the directives in this url https://docs.github.com/en/rest/commits/statuses When I hit the GitHub REST API with the following request, I get the response below:

 curl -H "Accept: application/vnd.github+json" -H "Authorization: token <TOKEN>" https://api.github.com/repos/andresdiegolanda/hello-world/commits/7f7e31e1956bb76e29fb94d1345954d5cb407c96

enter image description here

As you can see, there are no status in this commit. Then, I try to set a status in the commit with the following request, and I get the response below.

  curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token <TOKEN>" https://api.github.com/repos/andresdiegolanda/hello-world/578138334ad1f8dc874886ed2afb99e3265565be -d '{"state":"success","target_url":"https://example.com/build/status","description":"The build succeeded!","context":"continuous-integration/jenkins"}'

enter image description here

My question is: What am I doing wrong, that doesn't allow me to set the status in the request?

1
  • Tip: Checks are the successor of Commit Status. Commented Apr 9 at 13:44

1 Answer 1

2

The the Create commit status API

curl \
  -X POST \
  -H "Accept: application/vnd.github+json" \ 
  -H "Authorization: token <TOKEN>" \
  https://api.github.com/repos/OWNER/REPO/statuses/SHA \
  -d '{"state":"success","target_url":"https://example.com/build/status","description":"The build succeeded!","context":"continuous-integration/jenkins"}'

In your example:

https://api.github.com/repos/andresdiegolanda/hello-world/578138334ad1f8dc874886ed2afb99e3265565be

I did not see the /statuses/ part.

The other option is to use the GitHub CLI:

# GitHub CLI api
# https://cli.github.com/manual/gh_api

gh api \
  --method POST \
  -H "Accept: application/vnd.github+json" \
  /repos/OWNER/REPO/statuses/SHA \
  -f state='success'
 -f target_url='https://example.com/build/status'
 -f description='The build succeeded!'
 -f context='continuous-integration/jenkins'
Sign up to request clarification or add additional context in comments.

1 Comment

Brilliant. That worked. I was missing the "statuses"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.