Refactor how to call setup-ruby from other actions

* Automatically use inputs if available, use defaults otherwise.
This commit is contained in:
Benoit Daloze
2020-06-14 16:51:29 +02:00
parent d57231c9a3
commit c8a88df157
2 changed files with 18 additions and 12 deletions
Generated Vendored
+9 -6
View File
@@ -2199,20 +2199,23 @@ const inputDefaults = {
'working-directory': '.',
}
// entry point when this action is run on its own
async function run() {
try {
const options = {}
for (const key in inputDefaults) {
options[key] = core.getInput(key)
}
await setupRuby(options)
await setupRuby({})
} catch (error) {
core.setFailed(error.message)
}
}
// entry point when this action is run from other actions
async function setupRuby(options) {
const inputs = { ...inputDefaults, ...options }
const inputs = { ...options }
for (const key in inputDefaults) {
if (!inputs.hasOwnProperty(key)) {
inputs[key] = core.getInput(key) || inputDefaults[key]
}
}
process.chdir(inputs['working-directory'])
+9 -6
View File
@@ -13,20 +13,23 @@ const inputDefaults = {
'working-directory': '.',
}
// entry point when this action is run on its own
export async function run() {
try {
const options = {}
for (const key in inputDefaults) {
options[key] = core.getInput(key)
}
await setupRuby(options)
await setupRuby({})
} catch (error) {
core.setFailed(error.message)
}
}
// entry point when this action is run from other actions
export async function setupRuby(options) {
const inputs = { ...inputDefaults, ...options }
const inputs = { ...options }
for (const key in inputDefaults) {
if (!inputs.hasOwnProperty(key)) {
inputs[key] = core.getInput(key) || inputDefaults[key]
}
}
process.chdir(inputs['working-directory'])