Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display GitHub action badge for current running branch?

I need to show the GitHub action badge for the current running branch, instead, it is limited to one branch(default or specified).

like image 773
max Avatar asked Dec 06 '25 18:12

max


1 Answers

As the "Adding a workflow status badge" mentions, displaying the status of a workflow run for a specific branch or event is only done using the branch and event query parameters in the URL.

But those parameters are fixed. Modifying them would mean updating the README every time a new action is running.

Said action can get the name of the branch it operates on (see "How to get the current branch within GitHub Actions?")

But you would then need to combine that action with, for instance, github-update-readme in order to include the right URL for the badge:

![example](https://github.com/github/docs/actions/workflows/main.yml/badge.svg?branch=${GH_BRANCH})
                                                                                        ^^^^^^^^^^
                                       (value computed from the previous step by your main action)
like image 188
VonC Avatar answered Dec 08 '25 11:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!