fix: append EOL after value in GITHUB_STATE

This commit is contained in:
Antoine Cotten
2023-01-27 18:39:37 +01:00
parent cc576ce25a
commit f4951ec52e

View File

@@ -26,7 +26,8 @@
* * https://github.com/actions/runner/issues/1478 * * * https://github.com/actions/runner/issues/1478 *
* ================================================================================================================== */ * ================================================================================================================== */
const { spawn } = require("child_process"); const { spawn } = require("child_process");
const fs = require('fs'); const { appendFileSync } = require("fs");
const { EOL } = require("os");
function run(cmd) { function run(cmd) {
const subprocess = spawn(cmd, { stdio: "inherit", shell: true }); const subprocess = spawn(cmd, { stdio: "inherit", shell: true });
@@ -40,6 +41,6 @@ const key = process.env.INPUT_KEY.toUpperCase();
if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step? if ( process.env[`STATE_${key}`] !== undefined ) { // Are we in the 'post' step?
run(process.env.INPUT_POST); run(process.env.INPUT_POST);
} else { // Otherwise, this is the main step } else { // Otherwise, this is the main step
fs.appendFileSync(process.env.GITHUB_STATE, `${key}=true`); appendFileSync(process.env.GITHUB_STATE, `${key}=true${EOL}`);
run(process.env.INPUT_MAIN); run(process.env.INPUT_MAIN);
} }