根据提交构建状态创建 GitHub 自述文件构建状态徽章?

发布于 2025-01-11 09:26:53 字数 1538 浏览 4 评论 0原文

上下文

我想消除 CI 向 GitHub 手动导出构建状态徽章的情况。为此,我打算在存储库 repo_aREADME.md 中创建/使用构建状态徽章,它反映了头提交 head_commit_c 的构建状态 ofbranch branch_b 分支头的状态。 head_commit_c 的构建状态已由我的自托管 CI 设置,因此我希望我不必再输出构建状态徽章。

问题

(如何)可以在 GitHub 存储库 repo_a 的 README.md 中设置构建状态徽章,其中分支 branch_b 基于该分支的最新(HEAD)提交 commit_c

相关示例

在此存储库 我看到一些 Markdown 徽章包含 .js。我假设这能够以某种方式检索 GitHub 存储库的某些属性,例如星星的数量:

[![GitHub branches](https://badgen.net/github/branches/Naereen/Strapdown.js)](https://github.com/Naereen/Strapdown.js/)

所以我认为可能有一个相关的 .js 文件可以解析最新的 GitHub 提交状态并将其转换到 .svg/badge 中。

尝试我

根据评论中链接的文档,我尝试了:

![example branch parameter](https://github.com/github/docs/actions/workflows/main.yml/badge.svg?branch=main)

哪个返回: 输入图片这里的描述

我认为这是因为它指的是工作流文件 在本例中不存在,因为我运行自己的 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:

[![GitHub branches](https://badgen.net/github/branches/Naereen/Strapdown.js)](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:

![example branch parameter](https://github.com/github/docs/actions/workflows/main.yml/badge.svg?branch=main)

Which returns:
enter image description here

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文