Skip to main content

添加工作流程状态徽章

您可以在您的仓库中显示状态徽章,以指示您的工作流程状态。

Note: Workflow badges in a private repository are not accessible externally, so you won't be able to embed them or link to them from an external site.

状态徽章显示工作流程目前失败还是通过。 添加状态徽章的常见位置是仓库的 README.md 文件,但也可将其添加到您喜欢的任何网页。 默认情况下,徽章显示默认分支的状态。 您也可以在 URL 中使用 branchevent 查询参数显示特定分支或事件运行的工作流程状态。

示例状态徽章

To add a workflow status badge to your README.md file, first find the URL for the status badge you would like to display. Then you can use Markdown to display the badge as an image in your README.md file. For more information about image markup in Markdown, see "Basic writing and formatting syntax."

使用工作流程文件名称

You can build the URL for a workflow status badge using the name of the workflow file:

https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/<WORKFLOW_FILE>/badge.svg

To display the workflow status badge in your README.md file, use the Markdown markup for embedding images. For more information about image markup in Markdown, see "Basic writing and formatting syntax."

For example, add the following Markdown to your README.md file to add a status badge for a workflow with the file path .github/workflows/main.yml. 仓库的 OWNERgithub 组织,REPOSITORY 名称为 docs

![example workflow](https://github.com/github/docs/actions/workflows/main.yml/badge.svg)

使用 branch 参数

To display the status of a workflow run for a specific branch, add ?branch=<BRANCH_NAME> to the end of the status badge URL.

For example, add the following Markdown to your README.md file to display a status badge for a branch with the name feature-1.

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

使用 event 参数

To display the status of workflow runs triggered by the push event, add ?event=push to the end of the status badge URL.

For example, add the following Markdown to your README.md file to display a badge with the status of workflow runs triggered by the push event, which will show the status of the build for the current state of that branch.

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