Skip to content

Commit b4f4cc6

Browse files
author
Cole Kennedy
committed
.
1 parent c08f8ef commit b4f4cc6

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

index.js

+30-5
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,18 @@ async function runActionWithWitness(actionDir, witnessOptions) {
506506
const nodeCmd = 'node';
507507
const nodeArgs = [entryFile];
508508

509-
// Execute the command and capture its output
510-
const runArray = ["witness", ...cmd, "--", nodeCmd, ...nodeArgs],
511-
commandString = runArray.join(" ");
509+
// Prepare environment variables explicitly for the nested action
510+
const envVarsForCmd = Object.entries(nestedInputs).map(
511+
([name, value]) => `INPUT_${name.toUpperCase()}="${value.replace(/"/g, '\\"')}"`
512+
);
513+
514+
// Build the command with explicit environment variables
515+
const runArray = ["witness", ...cmd, "--", "env", ...envVarsForCmd, nodeCmd, ...nodeArgs];
516+
const commandString = runArray.join(" ");
512517

513518
core.info(`Running witness command: ${commandString}`);
514519

515520
// Set up options for execution
516-
517521
//debug print env vars
518522
console.log("Environment variables for nested action:");
519523
console.log
@@ -670,8 +674,29 @@ async function runDirectCommandWithWitness(command, witnessOptions) {
670674
// Parse the command into an array if it's not already
671675
const commandArray = command.match(/(?:[^\s"]+|"[^"]*")+/g) || [command];
672676

677+
// Get inputs with 'input-' prefix for the direct command as well
678+
const inputPrefix = 'input-';
679+
const nestedInputs = {};
680+
681+
// Get all inputs that start with 'INPUT_'
682+
Object.keys(process.env)
683+
.filter(key => key.startsWith('INPUT_'))
684+
.forEach(key => {
685+
const inputName = key.substring(6).toLowerCase(); // Remove 'INPUT_' prefix
686+
if (inputName.startsWith(inputPrefix)) {
687+
const nestedInputName = inputName.substring(inputPrefix.length);
688+
nestedInputs[nestedInputName] = process.env[key];
689+
core.info(`Passing input '${nestedInputName}' to direct command`);
690+
}
691+
});
692+
693+
// Prepare environment variables explicitly for the command
694+
const envVarsForCmd = Object.entries(nestedInputs).map(
695+
([name, value]) => `INPUT_${name.toUpperCase()}="${value.replace(/"/g, '\\"')}"`
696+
);
697+
673698
// Execute the command and capture its output
674-
const runArray = ["witness", ...cmd, "--", ...commandArray];
699+
const runArray = ["witness", ...cmd, "--", "env", ...envVarsForCmd, ...commandArray];
675700
const commandString = runArray.join(" ");
676701

677702
core.info(`Running witness command: ${commandString}`);

0 commit comments

Comments
 (0)