Badges for students if cloned from template repo

I’m new to GitHub’s template repositories. We’ve created a template repo for our course’s code labs. Let’s say it’s on GitHub under myorg/labX . The students are using GitHub Classroom for the assignment, which clones the template repo for each student under myorg/labX-studentlogin . We’ve got actions to run some tests against their code using GitHub’s own CI, and I want to include badges in the repo’s README.md to see the test results at a glance. So I know that

![](https://github.com/myorg/labX/workflows/task1/badge.svg)

will include the badge, but this is the status of the template repo, not student repos. Is there a way to automate this so that when the students get their clone, it will contain a README with the URL that refers to the status of their own repo?

2 Likes

I was looking for exactly this in the past but I’m afraid there’s no way to get it.

Turns out there is a simple solution, but only for GitHub’s own Actions status badges. We’ve changed the image URL in our README.mds to relative.
The only minor thing is GitHub will insert /blob/<branch>/ into relative links when rendering the readmes.
For example, workflows/task1/badge.svg will become https://github.com/myorg/labX/blob/master/workflows/task1/badge.svg), which won’t render. So we had to prepend '../../' to fool it.

TLDR: in repo’s README.md, use

![](../../workflows/<workflowname>/badge.svg)

to get a badge for an Action status in this repo. This way, each student will get a badge referring to his own repo, not the template repo.

However, still no luck if you use an external badge service like shields.io

3 Likes

Thanks for reporting this solution @av-pavlov :+1:
I was aware of the relative paths but didn’t know they work for GH Actions as well.