使用 SSH 在 Bash 中设置 GitHub 提交构建状态?

Set GitHub commit build status in Bash using SSH?

在尝试通过 ssh 设置提交的构建状态时,我遇到了一些困难。我首先使用 GitHub personal access token. Based on 成功设置了构建状态,我创建了以下 curl 命令:

#!/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.whosebug.com"}' https://api.github.com/repos/$USER/$REPO/statuses/$COMMIT_SHA

设置构建状态类似于下面的红叉:

接下来,我检索了 GitHub 提交状态,使用:

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

输出:

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

符合预期。

然后对于第二部分,我尝试省略使用 GitHub 个人访问令牌,并使用我的 ssh 凭据设置提交构建状态。但是,this answer 似乎表明这目前是不可能的。因此,我想问一下:

如何在 Bash 中使用 ssh 凭据设置 GitHub 提交构建状态?

我坚持我的 2013 answer 并确认,在 2021 年底,似乎不支持将 SSH 用于 GitHub API URL。

即使是最新的 GitHub CLI gh api 命令也只建议 HTTPS 调用,而不是 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.