GitHub Action
Badge Action
This action generates a SVG badge using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers). The badge is generated using the NPM package gradient-badge and Github Badge Action to read and write the GitHub Actions inputs and outputs.
Required The left label of the badge, usually static.
Required Hex or named color for the label. Default: 555
Required The right status as the badge, usually based on results.
Required An array (comma separated) with hex or named colors of the badge value background. More than one creates gradient background. Default: blue
.
Required Badge style: flat or classic. Default: classic
Use icon.
Set this if icon is not square. Default: 13
Set badge scale. Default: 1
The file path to store the badge image file. Only output to badge
action output if not defined.
The badge SVG contents.
uses: emibcn/[email protected]
with:
label: 'Test coverage'
status: '53.4%'
color: 'blue,555,daf'
path: '.github/badges/coverage.svg'
Create the dedicated branch badges
with (extracted from StackOverflow):
git checkout master
git checkout --orphan badges
# Unstage all the files in your working tree.
git rm --cached $(git ls-files)
# Create a dedicated README file, so it's clear what's going on here
echo '# Badges branch' > README.md
git add README.md
git commit -m 'Add dedicated README'
git push origin badges
And then, follow the example.
See a workflow example. Or another more complex example.
Note: You will need to pull auto-generated commits with this technique, or your repo will mess up.