@@ -275,6 +275,7 @@ async function runActionWithWitness(actionDir, witnessOptions) {
275
275
mavenPOM,
276
276
} = witnessOptions ;
277
277
278
+ // Read the nested action metadata (action.yml or action.yaml)
278
279
const actionYmlPath = path . join ( actionDir , "action.yml" ) ;
279
280
const actionYamlPath = path . join ( actionDir , "action.yaml" ) ;
280
281
let actionConfig ;
@@ -290,31 +291,26 @@ async function runActionWithWitness(actionDir, witnessOptions) {
290
291
throw new Error ( "Entry point (runs.main) not defined in action metadata" ) ;
291
292
}
292
293
core . info ( `Nested action entry point: ${ entryPoint } ` ) ;
294
+
293
295
const entryFile = path . join ( actionDir , entryPoint ) ;
294
296
if ( ! fs . existsSync ( entryFile ) ) {
295
297
throw new Error ( `Entry file ${ entryFile } does not exist.` ) ;
296
298
}
299
+
300
+ // Optionally install dependencies if package.json exists
297
301
const pkgJsonPath = path . join ( actionDir , "package.json" ) ;
298
302
if ( fs . existsSync ( pkgJsonPath ) ) {
299
303
core . info ( "Installing dependencies for nested action..." ) ;
300
304
await exec . exec ( "npm" , [ "install" ] , { cwd : actionDir } ) ;
301
305
}
302
306
303
- // FIX: Explicitly gather and inject INPUT_* variables.
304
- const nestedInputs = { } ;
305
- Object . keys ( process . env )
306
- . filter ( key => key . startsWith ( 'INPUT_' ) )
307
- . forEach ( key => {
308
- const inputName = key . substring ( 6 ) . toLowerCase ( ) ;
309
- nestedInputs [ inputName ] = process . env [ key ] ;
310
- core . info ( `Passing input '${ inputName } ' to nested action` ) ;
311
- } ) ;
312
- // Merge with process.env so that the child gets all environment variables.
307
+ // Build environment by merging process.env (ensuring all INPUT_* variables pass)
313
308
const envVars = { ...process . env } ;
314
- Object . keys ( nestedInputs ) . forEach ( name => {
315
- envVars [ `INPUT_ ${ name . toUpperCase ( ) } ` ] = nestedInputs [ name ] ;
316
- } ) ;
309
+ // (Optionally, override specific inputs explicitly if needed)
310
+ // For example:
311
+ // envVars["INPUT_WHO-TO-GREET"] = core.getInput("who-to-greet" );
317
312
313
+ // Build the witness command argument array.
318
314
const cmd = [ "run" ] ;
319
315
if ( enableSigstore ) {
320
316
fulcio = fulcio || "https://fulcio.sigstore.dev" ;
@@ -364,38 +360,42 @@ async function runActionWithWitness(actionDir, witnessOptions) {
364
360
}
365
361
if ( trace ) cmd . push ( `--trace=${ trace } ` ) ;
366
362
if ( outfile ) cmd . push ( `--outfile=${ outfile } ` ) ;
367
-
368
- const nodeCmd = 'node' ;
363
+
364
+ // Build argument array for the nested action execution
365
+ const nodeCmd = "node" ;
369
366
const nodeArgs = [ entryFile ] ;
370
- const runArray = [ "witness" , ...cmd , "--" , nodeCmd , ...nodeArgs ] ;
371
- const commandString = runArray . join ( " " ) ;
372
- core . info ( `Running witness command: ${ commandString } ` ) ;
373
-
374
- console . log ( "Environment variables for nested action:" ) ;
375
- for ( const key in envVars ) {
376
- console . log ( key + ": " + envVars [ key ] ) ;
377
- }
378
-
367
+ const args = [ ...cmd , "--" , nodeCmd , ...nodeArgs ] ;
368
+ core . info ( `Running witness command: witness ${ args . join ( " " ) } ` ) ;
369
+
379
370
const execOptions = {
380
371
cwd : actionDir ,
381
372
env : envVars ,
382
373
listeners : {
383
- stdout : data => process . stdout . write ( data . toString ( ) ) ,
384
- stderr : data => process . stderr . write ( data . toString ( ) )
374
+ stdout : ( data ) => process . stdout . write ( data . toString ( ) ) ,
375
+ stderr : ( data ) => process . stderr . write ( data . toString ( ) )
385
376
}
386
377
} ;
387
- let output = '' ;
388
- await exec . exec ( 'sh' , [ '-c' , commandString ] , {
378
+
379
+ let output = "" ;
380
+ // Directly call the witness binary without using a shell.
381
+ await exec . exec ( "witness" , args , {
389
382
...execOptions ,
390
383
listeners : {
391
384
...execOptions . listeners ,
392
- stdout : data => { output += data . toString ( ) ; process . stdout . write ( data . toString ( ) ) ; } ,
393
- stderr : data => { output += data . toString ( ) ; process . stderr . write ( data . toString ( ) ) ; }
385
+ stdout : ( data ) => {
386
+ output += data . toString ( ) ;
387
+ process . stdout . write ( data . toString ( ) ) ;
388
+ } ,
389
+ stderr : ( data ) => {
390
+ output += data . toString ( ) ;
391
+ process . stderr . write ( data . toString ( ) ) ;
392
+ }
394
393
}
395
394
} ) ;
396
395
return output ;
397
396
}
398
397
398
+
399
399
async function runDirectCommandWithWitness ( command , witnessOptions ) {
400
400
let {
401
401
step,
0 commit comments