Informing the user on details of your build and test results
In this recipe, we are going to decorate pull requests and workflow summaries with details of our test results. We’ll also add badges to the README file to indicate the quality of a branch or release.
Getting ready
Create a new branch to do the modification:
$ git switch -c add-badges
How to do it…
You can download badges for workflows using the following URL:
https://github.com/OWNER/REPO/actions/workflows/FILE.yml/badge.svg
You can also filter by branch or event by adding query parameters (for example, ?branch=main
or ?event=push
). We want a badge for the main
branch, so add the following image to the markdown of your README:
![main](https://github.com/OWNER/package-recipe/actions/workflows/ci.yml/badge.svg?branch=main)
The badge will use the name in the workflow file and look like Figure 6.4 in the preview:
Figure 6.4 – Badge for the CI workflow
...