Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Color range example #19

Merged
merged 3 commits into from Oct 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/badges.yml
Expand Up @@ -21,3 +21,39 @@ jobs:
maxColorRange: 100
minColorRange: 0

color-range-badges:
name: "Create Color Range Badges"
runs-on: ubuntu-latest
strategy:
matrix:
total:
- 0
- 10
- 20
- 30
- 40
- 50
- 60
- 70
- 80
- 90
- 100
steps:
- name: "Stagger"
run: |
# Gist returns 500 if we try to update many files in the same gist all at once.
# Thanks to Ned Batchelder for this idea!
# https://nedbatchelder.com/blog/202209/making_a_coverage_badge.html
sleep $( expr ${{ matrix.total }} / 10 )
- name: "Make badge"
uses: schneegans/dynamic-badges-action@master
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 2ab8f1d386f13aaebccbd87dac94068d
filename: color_badge_${{ matrix.total }}.json
label: Coverage
message: ${{ matrix.total }}%
minColorRange: 50
maxColorRange: 90
valColorRange: ${{ matrix.total }}

17 changes: 15 additions & 2 deletions README.md
Expand Up @@ -96,7 +96,20 @@ Parameter | Description

### Color Range Parameters (optional)

Starting with version 1.3.0 of this action, the color of the right side of the badge can be computed automatically on a green-to-red color-scale.
Starting with version 1.3.0 of this action, the color of the right side of the badge can be computed automatically on a green-to-red color-scale. For example, these badges have been colored with `minColorRange: 50` and `maxColorRange: 90`:

[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_0.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_10.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_20.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_30.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_40.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_50.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)<br>
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_60.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_70.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_80.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_90.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)
[![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/color_badge_100.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)

For this, the following parameters can be used.

Parameter | Description
Expand All @@ -109,7 +122,7 @@ Parameter | Description
`colorRangeLightness` | Lightness used by the color range feature. Defaults to 40.


### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)
### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d)

A common usage pattern of this action is to create environment variables in previous steps of a job and later use them as message in your badge.
How this can be done, is shown in the following example.
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -5,6 +5,7 @@
**Release Date:** TBD

* The gist is now not updated anymore if the content did not change. This prevents many gist revisions without actual changes. You can restore the original behavior by setting the optional `forceUpdate` parameter to `true`. A BIG thanks to [@MishaKav](https://github.com/MishaKav) for this contribution!
* Example color range badges have been added to the README.
* All node dependencies have been updated.

## [Dynamic Badges Action 1.4.0](https://github.com/Schneegans/dynamic-badges-action/tree/v1.4.0)
Expand Down