Is it possible to receive all inputs (in JavaScript Action) out of the GitHub action?
I understand this is possible to do when all inputs are predefined and input names are known, you just use 'core.getInput(“input-name”). What I am looking for is something along the lines of core.getAllInputs(), with an array as a result.
Or at least something like core.getAllInputNames(), with an array of all input names, so I can loop over that and get each individual input.
What core.getInput()
does is take the provided string, substitute spaces with underscores, convert to uppercase, prepend INPUT_
, and then use this string to look up an environment variable:
Therefore, you should be able to determine all input names by filtering the environment variables:
let inputs = Object.keys(process.env).filter(e => e.startsWith('INPUT_'))
Or for an object of inputs:
let inputs = {}
for (let [k,v] of Object.entries(process.env)) {
if (k.startsWith('INPUT_')) {
inputs[k] = v;
}
}
This is what I’m doing:
This isn’t quite JavaScript as I think about it, but it does what I need.