Reputation: 323
I need to show the GitHub action badge for the current running branch, instead, it is limited to one branch(default or specified).
Upvotes: 3
Views: 1616
Reputation: 1323863
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)
Upvotes: 2