Skip to main content

Adding a workflow status badge

You can display a status badge in your repository to indicate the status of your workflows.

注意

GitHub Enterprise Server 目前不支持 GitHub 托管的运行器。 可以在 GitHub public roadmap 上查看有关未来支持计划的更多信息。

注意

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 查询参数显示特定分支或事件的工作流运行的状态。

工作流状态徽章的屏幕截图。 从右到左显示:GitHub 徽标、工作流名称(“GitHub Actions 演示”)和状态(“正在传递”)。

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 基本撰写和格式语法.

Using the UI

You can create a workflow status badge directly on the UI using the workflow file name, branch parameter, and event parameter.

  1. 在 GitHub 上,导航到存储库的主页面。

  2. 在存储库名称下,单击 “操作”。

    “github/docs”存储库的选项卡的屏幕截图。 “操作”选项卡以橙色边框突出显示。

  3. 在左侧边栏中,单击您想要查看的工作流程。

    “操作”选项卡的左侧边栏的屏幕截图。工作流“CodeQL”以深橙色标出。

  4. On the right side of the page, next to the "Filter workflow runs" field, click to display a dropdown menu and click Create status badge.

  5. Optionally, select a branch if you want to display the status badge for a branch different from the default branch.

  6. Optionally, select the event that will trigger the workflow.

  7. Click Copy status badge Markdown.

  8. Copy the Markdown into your README.md file.

Using the workflow file name

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

HOSTNAME/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 基本撰写和格式语法.

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. The OWNER of the repository is the github organization and the REPOSITORY name is docs.

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

Using the branch parameter

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](http://github.com/github/docs/actions/workflows/main.yml/badge.svg?branch=feature-1)

Using the event parameter

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](http://github.com/github/docs/actions/workflows/main.yml/badge.svg?event=push)