diff --git a/README.md b/README.md index 7582270..9a0ae1d 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ Gist Parameter | Description `logoPosition` | The position of the logo. `style` | The style like "flat" or "social". `cacheSeconds` | The cache lifetime in seconds (must be greater than 300). +`maxColorRange` | Maximum value for the value passaed as message. Used to define the message color. +`minColorRange` | Minimum value for the value passaed as message. Used to define the message color. ### 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) diff --git a/action.yml b/action.yml index 36c8fc7..467f186 100644 --- a/action.yml +++ b/action.yml @@ -49,6 +49,12 @@ inputs: cacheSeconds: description: 'The cache lifetime in seconds (must be greater than 300)' required: false + maxColorRange: + description: 'Maximum value for the value passaed as message. Used to define the message color.' + required: false + minColorRange: + description: 'Minimum value for the value passaed as message. Used to define the message color.' + required: false runs: using: 'node12' main: 'index.js' diff --git a/index.js b/index.js index aa402b6..7a542a9 100644 --- a/index.js +++ b/index.js @@ -24,12 +24,22 @@ try { const logoPosition = core.getInput('logoPosition'); const style = core.getInput('style'); const cacheSeconds = core.getInput('cacheSeconds'); + const minColorRange = core.getInput('minColorRange'); + const maxColorRange = core.getInput('maxColorRange'); if (labelColor != '') { content.labelColor = labelColor; } - if (color != '') { + if (minColorRange != '' && maxColorRange != '') { + var max = parseFloat(maxColorRange); + var min = parseFloat(minColorRange); + var val = parseFloat(content.message); + if (val < min) val = min; + if (val > max) val = max; + let hue = Math.floor((val - min) / (max - min) * 100); + content.color = "hsl(" + hue + ", 100%, 50%)"; + } else if (color != '') { content.color = color; }