首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在GitHub中创建提交状态?

如何在GitHub中创建提交状态?
EN

Stack Overflow用户
提问于 2022-08-28 20:12:32
回答 1查看 22关注 0票数 1

我想在我的个人回购中设置一个提交状态。当我使用以下请求访问这个url https://docs.github.com/en/rest/commits/statuses中的GitHub REST时,我会得到下面的响应:

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

如您所见,此提交中没有状态。然后,我尝试使用以下请求在提交中设置状态,并得到下面的响应。

代码语言:javascript
复制
  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"}'

我的问题是:我做错了什么,不允许我在请求中设置状态?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-08-28 21:10:27

创建提交状态API

代码语言:javascript
复制
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"}'

在你的例子中:

代码语言:javascript
复制
https://api.github.com/repos/andresdiegolanda/hello-world/578138334ad1f8dc874886ed2afb99e3265565be

我没有看到/statuses/部分。

另一个选项是使用GitHub CLI

代码语言:javascript
复制
# 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'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73521934

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档