If you want to show the GitHub Actions badge on your repository, be aware that the URL has to reflect the name of a given action.
Do note GitHub actions are still in beta.
Like for example this badge for one of my repositories:
- The URL points to GitHub:
https://github.com
- My account:
jonasbn
- The relevant (this) repository:
til
- The workflows directory:
workflows
and this is theworkflows
directory located in the directory.github
- Now the most tricky part - the
name
fields from themain.yml
file from the above directory (github/workflows/
):
name: Markdownlint Workflow
on: push
jobs:
build:
name: Markdownlint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: ./github-action-markdownlint
This value:
name: Markdownlint Workflow
Okay, but since the specified name contains spaces, the have to be explicitly described using URI-encoding (or percent-encoding), meaning space is encoded %20
- Last but not least the hard-coded value:
badge.svg
So the complete URL for the badge displayes look as follows:
https://github.com/jonasbn/til/workflows/Markdownlint%20Workflow/badge.svg
Do yourself the favor of testing the URL before making commits containing it, it took me several attempts to get right.
Thanks to the nice supporter from GitHub who helped me out.
References
- Wikipedia: URI-encoding
- GitHub: "Setting up continuous integration using GitHub Actions"
- GitHub: "Adding a workflow status badge to your repository"
This TIL was lifted from my TIL collection
Top comments (4)
Thanks for this post. I always wanted add a badget like that.
Hi @douglasfugazi ,
I am glad you found it useful, for full documentation and a more proper process, the resource listed: "Adding a workflow status badge to your repository" is the best resource, my TIL is just a minor tweak/word of warning for a pitfall in the process.
Do let me know if it works for you, link to you repository or repositories most welcome.
Take care,
jonasbn
Thank you Jonas
I just blogged about using GitHub actions.
In the end if the post I demonstrate why it can be useful with more than one workflow, since it allows you to have MORE badges.
Check it out!