Badge image with workflow file path and specific branch?

Is it possible to get the GitHub Actions badge with workflow file path (e.g. .github/workflows/main.yml) and a branch (e.g. main)?

I tried a few combinations:

  • https://github.com/<OWNER>/<REPOSITORY>/workflows/.github/workflows/main.yml/badge.svg
    This seems to be either not working or working in random manner (the status don’t match the actual status)
  • https://github.com/<OWNER>/<REPOSITORY>/workflows/.github/workflows/main.yml/badge.svg?branch=main
    This fails miserably. Instead of showing any image, it only show a page with plain text: “Not Found”.

According to the documentation, it should be:

https://github.com/<OWNER>/<REPOSITORY>/actions/workflows/main.yml/badge.svg?branch=main

Note that it’s /actions/workflows as opposed to just /workflows like in your attempt, and that it doesn’t use the full path .github/workflows/main.yml but just the workflow file name main.yml.