Reputation: 1331
Does GitHub have an official badge for their new actions feature?
I came across this request on their official repo and there seems to be an official one:
https://github.com/{github_id}/{repository}/workflows/{workflow_name}/badge.svg
as per this comment, but I am unable to get it to work. Is it actually working? When I use it, I get the output below:
Note that I have replaced {github_id}
with my username
, {repository}
with my repo name and {workflow_name}
with the corresponding workflow name (removing the curly braces). Does anyone else have this issue?
Edit: I am working on a private repo, in case it makes a difference.
Upvotes: 37
Views: 17539
Reputation: 15173
You can get the actions badge by navigating to the required workflow on your repo on GitHub.com, clicking on the settings button on the right (the one with 3 dots beside the workflow search) and clicking on the Create status badge button.
Here, you can select the badge for the required branch and event and use the generated markdown.
For eg, below is the badge that I generated for the default branch and event of the CI
workflow of my fork:
The markdown for the above badge:
[![Build and Deploy](https://github.com/kratostaine/spring-authorization-server/actions/workflows/continuous-integration-workflow.yml/badge.svg)](https://github.com/kratostaine/spring-authorization-server/actions/workflows/continuous-integration-workflow.yml)
Upvotes: 73
Reputation: 331
I ran into another related problem of the name of the workflow containing spaces. These have to use URI escapes:
From main.yml
name: Hello World
Has to use a URI formatted like this:
https://github.com/{username}/{repository}/workflows/Hello%20World/badge.svg
This is not the right answer to the exact problem described here, but it is an alternative remedy to a problem demonstrating the same diagnostics - so I hope it helps somebody.
Upvotes: 5
Reputation: 2270
Worked for me:
[GITHUB-BADGE](https://github.com/{username}/{repository}/workflows/{name}/badge.svg)
More info here: Adding a workflow status badge to your repository
Upvotes: 7
Reputation: 1331
As it turns out, badge update/rendering is a slow process. After adding the badge to my README.md
, I just started off with work in another branch. After about 10 minutes (at least in my case), the badge appeared but the pipeline status was shown as 'unknown'. It updated again after about 10 minutes and with the correct pipeline status ('passing' in my case).
So, once you are done, just continue with your other stuff and it will update on its own, in sometime. Hope this helps someone!
Upvotes: 13