我想在我的个人回购中设置一个提交状态。当我使用以下请求访问这个url https://docs.github.com/en/rest/commits/statuses中的GitHub REST时,我会得到下面的响应:
curl -H "Accept: application/vnd.github+json" -H "Authorization: token <TOKEN>" https://api.github.com/repos/andresdiegolanda/hello-world/commits/7f7e31e1956bb76e29fb94d1345954d5cb407c96

如您所见,此提交中没有状态。然后,我尝试使用以下请求在提交中设置状态,并得到下面的响应。
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"}'

我的问题是:我做错了什么,不允许我在请求中设置状态?
发布于 2022-08-28 21:10:27
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"}'在你的例子中:
https://api.github.com/repos/andresdiegolanda/hello-world/578138334ad1f8dc874886ed2afb99e3265565be我没有看到/statuses/部分。
另一个选项是使用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'https://stackoverflow.com/questions/73521934
复制相似问题