From 785b28165f33e5eb8ecc718016717fd2f0cd5fb9 Mon Sep 17 00:00:00 2001 From: Nick Taylor Date: Thu, 29 Aug 2024 18:48:36 -0400 Subject: [PATCH] trying a bash script on the fly --- index.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 3d0d865..ee2dd6c 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,7 @@ const core = require("@actions/core"); const exec = require("@actions/exec"); +const fs = require("fs").promises; +const path = require("path"); async function run() { try { @@ -7,7 +9,25 @@ async function run() { const args = pizzaArgs.split(/\s+/).filter((arg) => arg.length > 0); console.log("Running Pizza CLI with args:", args); - await exec.exec("pizza", args); + + // Create a temporary bash script + const scriptContent = `#!/bin/bash +set -e +pizza ${args.map((arg) => `"${arg}"`).join(" ")} +`; + + const scriptPath = path.join(process.cwd(), "run_pizza.sh"); + console.log("Script content:", scriptContent); + console.log("Script path:", scriptPath); + + await fs.writeFile(scriptPath, scriptContent); + await fs.chmod(scriptPath, "0755"); // Make the script executable + + // Execute the bash script + await exec.exec(`bash ${scriptPath}`); + + // Remove the temporary script + await fs.unlink(scriptPath); // Add and commit changes await exec.exec("git config --global user.name github-actions"); @@ -16,6 +36,7 @@ async function run() { await exec.exec('git commit -m "Auto-commit from OpenSauced Pizza Action"'); await exec.exec("git push"); } catch (error) { + console.error("Error:", error); core.setFailed(error.message); } }