@@ -506,14 +506,18 @@ async function runActionWithWitness(actionDir, witnessOptions) {
506
506
const nodeCmd = 'node' ;
507
507
const nodeArgs = [ entryFile ] ;
508
508
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 ( " " ) ;
512
517
513
518
core . info ( `Running witness command: ${ commandString } ` ) ;
514
519
515
520
// Set up options for execution
516
-
517
521
//debug print env vars
518
522
console . log ( "Environment variables for nested action:" ) ;
519
523
console . log
@@ -670,8 +674,29 @@ async function runDirectCommandWithWitness(command, witnessOptions) {
670
674
// Parse the command into an array if it's not already
671
675
const commandArray = command . match ( / (?: [ ^ \s " ] + | " [ ^ " ] * " ) + / g) || [ command ] ;
672
676
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
+
673
698
// Execute the command and capture its output
674
- const runArray = [ "witness" , ...cmd , "--" , ...commandArray ] ;
699
+ const runArray = [ "witness" , ...cmd , "--" , "env" , ... envVarsForCmd , ...commandArray ] ;
675
700
const commandString = runArray . join ( " " ) ;
676
701
677
702
core . info ( `Running witness command: ${ commandString } ` ) ;
0 commit comments