1

While trying to set the build status of a commit through ssh, I was experiencing some difficulties. I first set the build status successfully, using a GitHub personal access token. Based on this answer, I created the following curl command:

#!/bin/bash
USER="red"
REPO="code"
COMMIT_SHA="6ec8d6ef221c3e317fa20b1f541770b8f46f065c"
MY_TOKEN="somelongpersonaltoken"
curl -H "Authorization: token $MY_TOKEN" --request POST --data '{"state": "failure", "description": "Failed!", "target_url": "https://www.stackoverflow.com"}' https://api.github.com/repos/$USER/$REPO/statuses/$COMMIT_SHA

Which sets the build status similar to the red cross below: enter image description here

Next, I retrieved the GitHub commit status, using:

GET https://api.github.com/repos/$USER/$REPO/commits/$COMMIT_SHA/statuses

Which outputs:

[{"url":"https://api.github.com/repos/... ,"state":"failure","description":"Failed!","target_url":"https://www.stackoverflow.com","context":"default","created_at":"2021-12-19T10:10:20Z","updated_at":"2021-12-19T10:10:20Z"...,"site_admin":false}}]

Which is as expected.

Then for the second part, I tried to omit using a GitHub personal access token, and use my ssh credentials to set the commit build status. However, this answer seems to suggest that that is currently not possible. Hence, I would like to ask:

How can I set a GitHub commit build status using ssh credentials in Bash?

a.t.
  • 2,002
  • 3
  • 26
  • 66

1 Answers1

1

I stand by my 2013 answer and confirm, in late 2021, that using SSH for GitHub API URL seems not supported.

Even the latest GitHub CLI gh api command only proposes HTTPS calls, not SSH.

Makes an authenticated HTTP request to the GitHub API and prints the response.

The endpoint argument should either be a path of a GitHub API v3 endpoint, or "graphql" to access the GitHub API v4.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250