How to Add a GitHub Actions Badge to Your Project
Rob Waller

Rob Waller @robdwaller

About: I am a developer with a passion for testing. I've been coding for 14 years and I want to share my experience and learnings with other developers to help them write better software.

Location:
Aylesbury, UK
Joined:
May 14, 2017

How to Add a GitHub Actions Badge to Your Project

Publish Date: Mar 20 '20
38 6

I've been playing with GitHub Actions for a couple of months now. I had been an ardent Travis loyalist, but given how impressive GitHub Actions are it feels inevitable I will make the switch.

One thing which tripped me up though was how to add GitHub Actions badges to my projects. This is so I can provide some observability and prove my projects build and the tests pass.

It turns out it is really simple, but it doesn't seem to be well documented anywhere. So I thought I'd make a note of it and share it.

To add a GitHub Actions badge to your project just use the following markdown. Obviously fill in the relevant {user}, {repo} and {action} information:

[![Actions Status](https://github.com/{user}/{repo}/workflows/{action}/badge.svg)](https://github.com/{user}/{repo}/actions)
Enter fullscreen mode Exit fullscreen mode

One thing which can be a little confusing is what the {action} name should be. This should reference the name property in the yaml action config file within your ./.github/workflows directory.

For a Rust project I recently worked on this is Build and Test.

name: Build and Test

on: [push]

jobs:
  build:
  ...
Enter fullscreen mode Exit fullscreen mode

The only change required for the badge URL is to replace the spaces with %20, so the URL {action} reference becomes Build%20and%20Test.

Here is an example from my Rust project which should make this clearer:

[![Actions Status](https://github.com/RobDWaller/csp-generator/workflows/Build%20and%20Test/badge.svg)](https://github.com/RobDWaller/csp-generator/actions)
Enter fullscreen mode Exit fullscreen mode

And you can see the working badge here:
Actions Status

I hope this info helps, have fun with GitHub Actions, and if you have any questions drop me a message @RobDWaller.

Comments 6 total

  • Sandor Dargo
    Sandor DargoSep 27, 2020

    This is great, I've been looking for this in the documentation and after all, once again, I ended up on DEV!
    Thanks!

  • Jéferson Chaves
    Jéferson ChavesOct 4, 2020

    Thanks for sharing it, Rob.

  • Anisha Mohanty
    Anisha MohantyDec 2, 2020

    This is quite useful. Thanks for sharing!

  • Amol
    AmolFeb 12, 2021

    Is it possible to link to the latest build page instead of the actions page?

  • Christopher Elias
    Christopher EliasMay 7, 2021

    Thank you! Really useful! I don't know why to GitHub doesn't specify this on their docs.

Add comment