Better status badges for GitHub actions
GitHub actions became pretty mature CI/CD product. So now it not really necessary to connect external tools like Travis to your repositories. If you want to start using it, please check documentation, it’s really simple.
But this article is about how default status badges looks like and how to improve them.
Update 03.2021: Seems that GitHub added recently this feature to badge generator. So you can just copy markdown from it and that’s it.
So, if you want to add status badge to the README.md in your repository, you need to go to the Actions tab in the repo, then select workflow and click button on the right side with three dots (…), then select “Create status badge”, example:
You’ll got something like this. And it pretty much works if you need only to show the status of workflow (in progress, pass, fail). When you click this link from readme file, you just got “badge.svg” opened.
But in other systems, this link usually leads to page where you can find workflows/pipelines, check their logs, etc.
Luckily, it’s possible to do as well with GitHub actions. You just need to slightly modify link. From
![test](https://github.com/Nklya/test-actions/workflows/test/badge.svg)
to
[![test](https://github.com/Nklya/test-actions/workflows/test/badge.svg)](https://github.com/Nklya/test-actions/actions?query=workflow%3Atest)
As you can see, link to worklow page was added to the end in round brackets ()
, while original link was enclosed in square brackets []
. After that, click on the status badge in README.md will lead to the worflow page.
Link to the workflow can be copied from the workflow page, check first picture. My example repo.
P.S. Keep in mind, that one status badge = 1 workflow. So if you have more than one, you need to repeat this.