根据提交构建状态创建 GitHub 自述文件构建状态徽章?
上下文
我想消除 CI 向 GitHub 手动导出构建状态徽章的情况。为此,我打算在存储库 repo_a
的 README.md
中创建/使用构建状态徽章,它反映了头提交 head_commit_c 的构建状态
ofbranch branch_b
分支头的状态。 head_commit_c
的构建状态已由我的自托管 CI 设置,因此我希望我不必再输出构建状态徽章。
问题
(如何)可以在 GitHub 存储库 repo_a
的 README.md 中设置构建状态徽章,其中分支 branch_b
基于该分支的最新(HEAD)提交 commit_c
?
相关示例
在此存储库 我看到一些 Markdown 徽章包含 .js
。我假设这能够以某种方式检索 GitHub 存储库的某些属性,例如星星的数量:
[](https://github.com/Naereen/Strapdown.js/)
所以我认为可能有一个相关的 .js 文件可以解析最新的 GitHub 提交状态并将其转换到 .svg
/badge 中。
尝试我
根据评论中链接的文档,我尝试了:

我认为这是因为它指的是工作流文件 在本例中不存在,因为我运行自己的 CI。
因此,如果这个名为 main.yml
的工作流文件可以直接将分支的构建状态结果链接到该分支中的最新提交状态,我想可以添加这样一个工作流文件。我还不确定是否确实如此,如果是,又是如何做到的。
注意
因此,我并不是指解析特定提交 url 的链接,而是指向最新提交构建状态的自动更新链接。
Context
I would like to eliminate the manual exporting of build status badges that my CI does to GitHub. To do this, I intend to create/use a build status badge in the README.md
of repo repo_a
, that reflects the build status of the head commit head_commit_c
of branch branch_b
status of the head of a branch. This build status of head_commit_c
is already set by my self-hosted CI, so I hope I won't also have to output the build status badge (anymore).
Question
(How) can one set a build status badge in a README.md
of a GitHub repository repo_a
with branch branch_b
based on the latest(HEAD) commit commit_c
of that branch?
Related example
In this repository I saw that some markdown badges contain a .js
. I assumed this is somehow able to retrieve some property of a GitHub repository, for example the amount of stars:
[](https://github.com/Naereen/Strapdown.js/)
So I thought there might be a related .js
file that parses the latest GitHub commit status and converts it into an .svg
/badge.
Attempt I
Based on the documentation linked in the comments, I tried:

I think this is because it refers to a workflow file which does not exist in this case, as I run my own CI.
So if this workflow file named main.yml
can directly link the build status result of a branch, to the latest commit status in that branch, I imagine one could add such a workflow file. I did not yet determine whether this indeed is the case, and if yes, how.
Note
So I do not mean a link that parses the url of a specific commit, but an automatically updated link to the latest commit build status.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论