Skip to content

Commit

Permalink
🔧 USe color range for example badge
Browse files Browse the repository at this point in the history
  • Loading branch information
Schneegans committed Apr 18, 2022
1 parent a3f7e7f commit 7ce4e74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/badges.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ jobs:
auth: ${{ secrets.GIST_SECRET }}
gistID: 2ab8f1d386f13aaebccbd87dac94068d
filename: answer.json
label: The Answer is
message: ${{ env.ANSWER }}
color: green
label: The Answer
message: is ${{ env.ANSWER }}
valColorRange: ${{ env.ANSWER }}
maxColorRange: 100
minColorRange: 0

14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ Parameter | Description

### 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)

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. This can be achieved like this:
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.

This example also shows how to use the automatic color range feature: If the answer is <= 0, the badge will be red, if it's >= 100 it will be green.
For all values in between, the color will be interpolated.

```yml
- name: Get the Numbers
Expand All @@ -115,9 +119,11 @@ A common usage pattern of this action is to create environment variables in prev
auth: ${{ secrets.GIST_SECRET }}
gistID: <gist-ID>
filename: answer.json
label: The Answer is
message: ${{ env.ANSWER }}
color: green
label: The Answer
message: is ${{ env.ANSWER }}
valColorRange: ${{ env.ANSWER }}
maxColorRange: 100
minColorRange: 0
```

## Contributing to Dynamic Badges Action
Expand Down

0 comments on commit 7ce4e74

Please sign in to comment.