Merge remote-tracking branch 'upstream/master' into dep-error-handling

This commit is contained in:
Piotr Kwiecinski 2024-03-07 19:37:09 +01:00
commit 24d8f1d22f
2 changed files with 18 additions and 11 deletions

View file

@ -48,6 +48,11 @@ inputs:
default: '' default: ''
description: Path to local Deployer binary. description: Path to local Deployer binary.
recipe:
required: false
default: ''
description: Recipe file path.
ansi: ansi:
required: false required: false
default: 'true' default: 'true'
@ -59,7 +64,7 @@ inputs:
description: Verbosity level Can be -v, -vv or -vvv. description: Verbosity level Can be -v, -vv or -vvv.
runs: runs:
using: 'node16' using: 'node20'
main: 'index.js' main: 'index.js'
branding: branding:

View file

@ -95,7 +95,7 @@ async function dep() {
} }
} }
if (typeof url === 'undefined') { if (typeof url === 'undefined') {
throw new Error(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`) core.setFailed(`The version "${version}"" does not exist in the "https://deployer.org/manifest.json" file."`)
} else { } else {
console.log(`Downloading "${url}".`) console.log(`Downloading "${url}".`)
await $`curl -LO ${url}` await $`curl -LO ${url}`
@ -106,24 +106,26 @@ async function dep() {
} }
let cmd = core.getInput('dep').split(' ') let cmd = core.getInput('dep').split(' ')
let recipe = core.getInput('recipe')
if (recipe !== '') {
recipe = `--file=${recipe}`
}
let ansi = core.getBooleanInput('ansi') ? '--ansi' : '--no-ansi' let ansi = core.getBooleanInput('ansi') ? '--ansi' : '--no-ansi'
let verbosity = core.getInput('verbosity') let verbosity = core.getInput('verbosity')
let options = [] let options = []
let optionsInput = core.getInput('options'); try {
let optionsArg = core.getInput('options')
if (optionsInput !== '') { if (optionsArg !== '') {
try { for (let [key, value] in Object.entries(JSON.parse(optionsArg))) {
for (let [key, value] in Object.entries(JSON.parse(optionsInput))) {
options.push('-o', `${key}=${value}`) options.push('-o', `${key}=${value}`)
} }
} catch (e) {
throw new Error('Invalid JSON in options')
} }
} }
try { try {
await $`php ${dep} ${cmd} --no-interaction ${ansi} ${verbosity} ${options}` await $`php ${dep} ${cmd} ${recipe} --no-interaction ${ansi} ${verbosity} ${options}`
} catch (err) { } catch (err) {
throw new Error(`Failed: dep ${cmd}`) core.setFailed(`Failed: dep ${cmd}`)
} }
} }