You've already forked dynamic-badges-action
🎉 Added more functionalities to color range
Now the Range can be inverted and doesn't use the message anymore
This commit is contained in:
@@ -80,8 +80,10 @@ Gist Parameter | Description
|
|||||||
`logoPosition` | The position of the logo.
|
`logoPosition` | The position of the logo.
|
||||||
`style` | The style like "flat" or "social".
|
`style` | The style like "flat" or "social".
|
||||||
`cacheSeconds` | The cache lifetime in seconds (must be greater than 300).
|
`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.
|
`valColorRange` | Numerical value used to define the message color.
|
||||||
`minColorRange` | Minimum value for the value passaed as message. Used to define the message color.
|
`maxColorRange` | Maximum value in the range used to define the message color.
|
||||||
|
`minColorRange` | Minimum value in the range used to define the message color.
|
||||||
|
`invertColorRange` | If the range should be inverted, causing a smaller value to have green color.
|
||||||
|
|
||||||
### Using Environment Variables as Parameters [](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)
|
### Using Environment Variables as Parameters [](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)
|
||||||
|
|
||||||
|
|||||||
10
action.yml
10
action.yml
@@ -49,11 +49,17 @@ inputs:
|
|||||||
cacheSeconds:
|
cacheSeconds:
|
||||||
description: 'The cache lifetime in seconds (must be greater than 300)'
|
description: 'The cache lifetime in seconds (must be greater than 300)'
|
||||||
required: false
|
required: false
|
||||||
|
valColorRange:
|
||||||
|
description: 'Numerical value used to define the message color.'
|
||||||
|
required: false
|
||||||
maxColorRange:
|
maxColorRange:
|
||||||
description: 'Maximum value for the value passaed as message. Used to define the message color.'
|
description: 'Maximum value in the range used to define the message color.'
|
||||||
required: false
|
required: false
|
||||||
minColorRange:
|
minColorRange:
|
||||||
description: 'Minimum value for the value passaed as message. Used to define the message color.'
|
description: 'Minimum value in the range used to define the message color.'
|
||||||
|
required: false
|
||||||
|
invertColorRange:
|
||||||
|
description: 'If the range should be inverted, causing a smaller value to have green color.'
|
||||||
required: false
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
|||||||
15
index.js
15
index.js
@@ -24,20 +24,29 @@ try {
|
|||||||
const logoPosition = core.getInput('logoPosition');
|
const logoPosition = core.getInput('logoPosition');
|
||||||
const style = core.getInput('style');
|
const style = core.getInput('style');
|
||||||
const cacheSeconds = core.getInput('cacheSeconds');
|
const cacheSeconds = core.getInput('cacheSeconds');
|
||||||
|
const valColorRange = core.getInput('valColorRange');
|
||||||
const minColorRange = core.getInput('minColorRange');
|
const minColorRange = core.getInput('minColorRange');
|
||||||
const maxColorRange = core.getInput('maxColorRange');
|
const maxColorRange = core.getInput('maxColorRange');
|
||||||
|
const invertColorRange = core.getInput('invertColorRange');
|
||||||
|
|
||||||
if (labelColor != '') {
|
if (labelColor != '') {
|
||||||
content.labelColor = labelColor;
|
content.labelColor = labelColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (minColorRange != '' && maxColorRange != '') {
|
if (minColorRange != '' && maxColorRange != '' && valColorRange != '') {
|
||||||
var max = parseFloat(maxColorRange);
|
var max = parseFloat(maxColorRange);
|
||||||
var min = parseFloat(minColorRange);
|
var min = parseFloat(minColorRange);
|
||||||
var val = parseFloat(content.message);
|
var val = parseFloat(valColorRange);
|
||||||
if (val < min) val = min;
|
if (val < min) val = min;
|
||||||
if (val > max) val = max;
|
if (val > max) val = max;
|
||||||
let hue = Math.floor((val - min) / (max - min) * 100);
|
var hue = 0
|
||||||
|
if (invertColorRange == '') {
|
||||||
|
hue = Math.floor((val - min) / (max - min) * 100);
|
||||||
|
message = val + " / " + max + " " + message
|
||||||
|
} else {
|
||||||
|
hue = Math.floor((max - val) / (max - min) * 100);
|
||||||
|
message = val + " " + message
|
||||||
|
}
|
||||||
content.color = "hsl(" + hue + ", 100%, 50%)";
|
content.color = "hsl(" + hue + ", 100%, 50%)";
|
||||||
} else if (color != '') {
|
} else if (color != '') {
|
||||||
content.color = color;
|
content.color = color;
|
||||||
|
|||||||
Reference in New Issue
Block a user