fix(app/docker): correctly parse input variables (#852)

This commit is contained in:
Simon Lecoq
2022-02-09 01:24:54 +01:00
committed by GitHub
parent 4983bad99d
commit 58ff5eee45
3 changed files with 35 additions and 15 deletions

View File

@@ -12,6 +12,9 @@ const categories = ["core", "github", "social", "community"]
//Previous descriptors
let previous = null
//Environment
const env = {ghactions:`${process.env.GITHUB_ACTIONS}` === "true"}
/**Metadata descriptor parser */
export default async function metadata({log = true, diff = false} = {}) {
//Paths
@@ -81,7 +84,7 @@ export default async function metadata({log = true, diff = false} = {}) {
const descriptor = yaml.load(`${await fs.promises.readFile(__descriptor, "utf-8")}`)
//Metadata
return {plugins:Plugins, templates:Templates, packaged, descriptor}
return {plugins:Plugins, templates:Templates, packaged, descriptor, env}
}
/**Metadata extractor for inputs */
@@ -244,14 +247,19 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
const q = {}
for (const key of Object.keys(inputs)) {
//Parse input
let value = `${core.getInput(key)}`.trim()
try {
value = decodeURIComponent(value)
}
catch {
logger(`metrics/inputs > failed to decode uri for ${key}: ${value}`)
value = "<default-value>"
let value
if (env.ghactions) {
value = `${core.getInput(key)}`.trim()
try {
value = decodeURIComponent(value)
}
catch {
logger(`metrics/inputs > failed to decode uri for ${key}: ${value}`)
value = "<default-value>"
}
}
else
value = process.env[`INPUT_${key.toUpperCase()}`]?.trim() ?? "<default-value>"
const unspecified = value === "<default-value>"
//From presets
if ((key in preset) && (unspecified)) {