fix(app/action): mishandled config_output (#1293)
This commit is contained in:
@@ -318,6 +318,9 @@ function quit(reason) {
|
||||
console.debug(error)
|
||||
}
|
||||
info("Previous render sha", committer.sha ?? "(none)")
|
||||
//Compatibility check
|
||||
if ((_action === "gist")&&(["png", "jpeg", "markdown-pdf"].includes(_output)))
|
||||
throw new Error(`"config_output: ${_output}" is not supported with "config_action: ${_action}"`)
|
||||
}
|
||||
else if (dryrun) {
|
||||
info("Dry-run", true)
|
||||
@@ -398,18 +401,21 @@ function quit(reason) {
|
||||
//Render metrics
|
||||
info.break()
|
||||
info.section("Rendering")
|
||||
let rendered = await retry(async () => {
|
||||
const {rendered, errors} = await metrics({login: user, q}, {graphql, rest, plugins, conf, die, verify, convert}, {Plugins, Templates})
|
||||
let {rendered, mime} = await retry(async () => {
|
||||
const {rendered, mime, errors} = await metrics({login: user, q}, {graphql, rest, plugins, conf, die, verify, convert}, {Plugins, Templates})
|
||||
if (errors.length) {
|
||||
console.warn(`::group::${errors.length} error(s) occurred`)
|
||||
console.warn(util.inspect(errors, {depth: Infinity, maxStringLength: 256}))
|
||||
console.warn("::endgroup::")
|
||||
}
|
||||
return rendered
|
||||
return {rendered, mime}
|
||||
}, {retries, delay: retries_delay})
|
||||
if (!rendered)
|
||||
throw new Error("Could not render metrics")
|
||||
info("Status", "complete")
|
||||
info("MIME type", mime)
|
||||
const buffer = typeof rendered === "object" ? rendered instanceof Buffer ? rendered : Buffer.from(JSON.stringify(rendered)) : Buffer.from(`${rendered}`)
|
||||
|
||||
|
||||
//Debug print
|
||||
if (dprint) {
|
||||
@@ -421,6 +427,7 @@ function quit(reason) {
|
||||
//Output condition
|
||||
info.break()
|
||||
info.section("Saving")
|
||||
if (_output === "svg") {
|
||||
info("Output condition", _output_condition)
|
||||
if ((_output_condition === "data-changed") && ((committer.commit) || (committer.pr))) {
|
||||
const {svg} = await import("../metrics/utils.mjs")
|
||||
@@ -443,13 +450,16 @@ function quit(reason) {
|
||||
if (!changed)
|
||||
committer.commit = false
|
||||
}
|
||||
}
|
||||
else
|
||||
info("Output condition", `Not applicable for ${_output}`)
|
||||
|
||||
//Save output to renders output folder
|
||||
if (dryrun)
|
||||
info("Actions to perform", "(none)")
|
||||
else {
|
||||
await fs.mkdir(paths.dirname(paths.join("/renders", filename)), {recursive: true})
|
||||
await fs.writeFile(paths.join("/renders", filename), Buffer.from(typeof rendered === "object" ? JSON.stringify(rendered) : `${rendered}`))
|
||||
await fs.writeFile(paths.join("/renders", filename), buffer)
|
||||
info(`Save to /metrics_renders/${filename}`, "ok")
|
||||
info("Output action", _action)
|
||||
}
|
||||
@@ -517,7 +527,7 @@ function quit(reason) {
|
||||
//Upload to gist (this is done as user since committer_token may not have gist rights)
|
||||
if (committer.gist) {
|
||||
await retry(async () => {
|
||||
await rest.gists.update({gist_id: committer.gist, files: {[filename]: {content: rendered}}})
|
||||
await rest.gists.update({gist_id: committer.gist, files: {[filename]: {content: buffer.toString()}}})
|
||||
info(`Upload to gist ${committer.gist}`, "ok")
|
||||
committer.commit = false
|
||||
}, {retries: retries_output_action, delay: retries_delay_output_action})
|
||||
@@ -530,7 +540,7 @@ function quit(reason) {
|
||||
...github.context.repo,
|
||||
path: filename,
|
||||
message: committer.message,
|
||||
content: Buffer.from(typeof rendered === "object" ? JSON.stringify(rendered) : `${rendered}`).toString("base64"),
|
||||
content: buffer.toString("base64"),
|
||||
branch: committer.pr ? committer.head : committer.branch,
|
||||
...(committer.sha ? {sha: committer.sha} : {}),
|
||||
})
|
||||
|
||||
@@ -106,6 +106,8 @@ inputs:
|
||||
- `gist`: push output to `committer_gist`
|
||||
|
||||
> 💡 When using `pull-request`, you will need to set the last job with a `pull-request-*` action instead, else it won't be merged
|
||||
|
||||
> ⚠️ As GitHub gists API does not support binary files upload, `gist` does not support [`config_output`](/source/plugins/core/README.md#config_output) set to either `png`, `jpeg` or `markdown-pdf`
|
||||
type: string
|
||||
default: commit
|
||||
values:
|
||||
|
||||
Reference in New Issue
Block a user