如何访问徽章中的 GitHub 操作输出

发布于 2025-01-13 07:56:45 字数 302 浏览 1 评论 0原文

我有一个输出数字的 GitHub 操作工作流程,我想将其显示在徽章中。

使用 https://github.com/username/reponame/actions/工作流/myaction.yml/badge.svg 我得到一个红色或绿色的失败/成功徽章,但我想显示失败的数量,工作流将其输出到“错误”输出变量中。

如何访问徽章中的该变量?

I have a GitHub action workflow that outputs a number and I want to display that in a badge.

Using https://github.com/username/reponame/actions/workflows/myaction.yml/badge.svg I get a red or green failing/success badge but I want to display the number of failures instead, which the workflow outputs into the "errors" output variable.

How can I access that variable in a badge?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

晨曦÷微暖 2025-01-20 07:56:45

选项很少

Github 操作市场中的“自带徽章” - https://github .com/marketplace/actions/bring-your-own-badge

BYOB 是一个 GitHub Action,可根据 GitHub Actions 的结果动态创建徽章,从而实现极其通用且易于维护的徽章。

如果您想使用 https://shields.io/,请考虑动态徽章 - https://github.com/marketplace/actions/dynamic-badges

此操作允许您使用shields.io为README.md创建徽章,该徽章可能会随着每次提交而改变。为此,此操作不需要将任何内容推送到您的存储库!

There are few options in Github actions marketplace

Bring Your Own Badge - https://github.com/marketplace/actions/bring-your-own-badge

BYOB is a GitHub Action to create badges dynamically based off of GitHub Actions' results, allowing for extremely versatile and easily-maintainable badges.

If you want to use https://shields.io/, consider Dynamic Badges - https://github.com/marketplace/actions/dynamic-badges

This action allows you to create badges for your README.md with shields.io which may change with every commit. To do this, this action does not need to push anything to your repository!

记忆里有你的影子 2025-01-20 07:56:45

您可以在同一工作流程中的后续作业(步骤)中。
我认为您想使用自己的徽章,例如 https://img.shields.io
我想您将在每次操作完成时更新自述文件,更新步骤将成为工作流程的一部分。输出的传输可以像这里一样完成 在 GitHub Action 的新作业中使用上一作业的输出

您将在自述文件中附加适当的 svg [![](https://img.shields.io/badge/TEXT-NUMBER-COLOR?style=flat)](some url)

In a subsequent job (step) in the same workflow you could.
I think you want to use your own badge using e.g. https://img.shields.io.
I image you will update e.g. the README file every time the actions are finished, the updating step will be part of the workflow. The transfer of output could be done like here Using output from a previous job in a new one in a GitHub Action.

You will append e.g. the README with a proper svg [![](https://img.shields.io/badge/TEXT-NUMBER-COLOR?style=flat)](some url).

棒棒糖 2025-01-20 07:56:45

我创建了一个操作来从工作流程生成徽章:

Build-A-Badge - https: //github.com/marketplace/actions/build-a-badge

正如其他用户所指出的,我不需要任何外部依赖项或在主存储库上创建新分支。因此,我使用的解决方法是将徽章数据存储在 Wiki 中,这是一个单独的存储库。

I created an action to generate a badge from a workflow:

Build-A-Badge - https://github.com/marketplace/actions/build-a-badge

As other users have pointed out, I didn't want any external dependencies or to create new branches on the main repo. So the workaround I used is to store the badge data in the Wiki, which is a separate repository.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文