@@ -34,9 +34,28 @@ actionTimeoutId.unref();
3434async function run ( ) {
3535 try {
3636 // Step 1: Get Witness-related inputs
37- const witnessVersion = core . getInput ( "witness-version" ) || "0.2.11 " ;
37+ const witnessVersion = core . getInput ( "witness-version" ) || "0.8.1 " ;
3838 const witnessInstallDir = core . getInput ( "witness-install-dir" ) || "./" ;
3939
40+ // Log all inputs for debugging purposes
41+ core . info ( `Action inputs received:` ) ;
42+ Object . keys ( process . env )
43+ . filter ( key => key . startsWith ( 'INPUT_' ) )
44+ . forEach ( key => {
45+ // Mask sensitive inputs
46+ const isSensitive = key . includes ( 'TOKEN' ) || key . includes ( 'KEY' ) ;
47+ const value = isSensitive ? '***' : process . env [ key ] ;
48+ core . info ( ` ${ key } =${ value } ` ) ;
49+ } ) ;
50+
51+ // Specifically check if input-who-to-greet exists, which is needed for the hello-world action
52+ const whoToGreet = core . getInput ( 'input-who-to-greet' ) ;
53+ if ( whoToGreet ) {
54+ core . info ( `Found input-who-to-greet=${ whoToGreet } ` ) ;
55+ } else {
56+ core . warning ( `No input-who-to-greet found in inputs - this may cause issues with the hello-world action` ) ;
57+ }
58+
4059 // Step 2: First download Witness binary
4160 await downloadWitness ( witnessVersion , witnessInstallDir ) ;
4261
@@ -465,14 +484,28 @@ async function runActionWithWitness(actionDir, witnessOptions) {
465484
466485 let actionConfig ;
467486
487+ let actionYmlContent ;
468488 if ( fs . existsSync ( actionYmlPath ) ) {
469- actionConfig = yaml . load ( fs . readFileSync ( actionYmlPath , "utf8" ) ) ;
489+ actionYmlContent = fs . readFileSync ( actionYmlPath , "utf8" ) ;
490+ actionConfig = yaml . load ( actionYmlContent ) ;
470491 } else if ( fs . existsSync ( actionYamlPath ) ) {
471- actionConfig = yaml . load ( fs . readFileSync ( actionYamlPath , "utf8" ) ) ;
492+ actionYmlContent = fs . readFileSync ( actionYamlPath , "utf8" ) ;
493+ actionConfig = yaml . load ( actionYmlContent ) ;
472494 } else {
473495 throw new Error ( `Neither action.yml nor action.yaml found in ${ actionDir } ` ) ;
474496 }
475497
498+ // Debug: Log the action's inputs section
499+ if ( actionConfig . inputs ) {
500+ core . info ( `Nested action inputs: ${ JSON . stringify ( Object . keys ( actionConfig . inputs ) ) } ` ) ;
501+ // Check specifically for the who-to-greet input
502+ if ( actionConfig . inputs [ 'who-to-greet' ] ) {
503+ core . info ( `Found 'who-to-greet' input in action definition. Required: ${ actionConfig . inputs [ 'who-to-greet' ] . required } ` ) ;
504+ } else {
505+ core . warning ( `Nested action doesn't define 'who-to-greet' input in its action.yml!` ) ;
506+ }
507+ }
508+
476509 const entryPoint = actionConfig . runs && actionConfig . runs . main ;
477510 if ( ! entryPoint ) {
478511 throw new Error ( "Entry point (runs.main) not defined in action metadata" ) ;
@@ -489,6 +522,21 @@ async function runActionWithWitness(actionDir, witnessOptions) {
489522 const pkgJsonPath = path . join ( actionDir , "package.json" ) ;
490523 if ( fs . existsSync ( pkgJsonPath ) ) {
491524 core . info ( "Installing dependencies for nested action..." ) ;
525+
526+ // Log package.json contents for debugging
527+ try {
528+ const pkgJson = require ( pkgJsonPath ) ;
529+ core . info ( `Nested action package.json name: ${ pkgJson . name } , version: ${ pkgJson . version } ` ) ;
530+ if ( pkgJson . dependencies ) {
531+ core . info ( `Dependencies: ${ JSON . stringify ( pkgJson . dependencies ) } ` ) ;
532+ }
533+ if ( pkgJson . inputs ) {
534+ core . info ( `Action inputs: ${ JSON . stringify ( pkgJson . inputs ) } ` ) ;
535+ }
536+ } catch ( error ) {
537+ core . warning ( `Could not read package.json: ${ error . message } ` ) ;
538+ }
539+
492540 await exec . exec ( "npm" , [ "install" ] , { cwd : actionDir } ) ;
493541 }
494542
@@ -502,19 +550,68 @@ async function runActionWithWitness(actionDir, witnessOptions) {
502550 . filter ( key => key . startsWith ( 'INPUT_' ) )
503551 . forEach ( key => {
504552 const inputName = key . substring ( 6 ) . toLowerCase ( ) ; // Remove 'INPUT_' prefix
505- if ( inputName . startsWith ( inputPrefix ) ) {
506- const nestedInputName = inputName . substring ( inputPrefix . length ) ;
553+ // Convert underscores in input name to hyphens for matching with input-prefix
554+ const normalizedInputName = inputName . replace ( / _ / g, '-' ) ;
555+
556+ if ( normalizedInputName . startsWith ( inputPrefix ) ) {
557+ const nestedInputName = normalizedInputName . substring ( inputPrefix . length ) ;
507558 nestedInputs [ nestedInputName ] = process . env [ key ] ;
508559 core . info ( `Passing input '${ nestedInputName } ' to nested action` ) ;
509560 }
510561 } ) ;
562+
563+ // Debug all input values (use core.debug to reduce noise in normal execution)
564+ core . debug ( "All available inputs:" ) ;
565+ Object . keys ( process . env )
566+ . filter ( key => key . startsWith ( 'INPUT_' ) )
567+ . forEach ( key => {
568+ // Mask sensitive inputs
569+ const isSensitive = key . includes ( 'TOKEN' ) || key . includes ( 'KEY' ) ;
570+ const value = isSensitive ? '***' : process . env [ key ] ;
571+ core . debug ( `${ key } : ${ value } ` ) ;
572+ } ) ;
511573
512574 // Set environment variables for the nested action
513575 const envVars = { ...process . env } ;
576+
577+ // First add all inputs with the input- prefix
514578 Object . keys ( nestedInputs ) . forEach ( name => {
515- envVars [ `INPUT_${ name . toUpperCase ( ) } ` ] = nestedInputs [ name ] ;
579+ // Convert hyphens to underscores for environment variables
580+ const envName = name . replace ( / - / g, '_' ) . toUpperCase ( ) ;
581+ envVars [ `INPUT_${ envName } ` ] = nestedInputs [ name ] ;
582+ core . info ( `Set INPUT_${ envName } =${ nestedInputs [ name ] } ` ) ;
516583 } ) ;
517584
585+ // Also check if there are any inputs without the 'input-' prefix that might need to be passed
586+ Object . keys ( process . env )
587+ . filter ( key => key . startsWith ( 'INPUT_' ) && ! key . startsWith ( 'INPUT_INPUT_' ) )
588+ . forEach ( key => {
589+ // Skip action-wrapper specific inputs
590+ const skipInputs = [
591+ 'ACTION_REF' , 'COMMAND' , 'WITNESS_VERSION' , 'WITNESS_INSTALL_DIR' ,
592+ 'STEP' , 'ATTESTATIONS' , 'OUTFILE' , 'ENABLE_ARCHIVISTA' , 'ARCHIVISTA_SERVER' ,
593+ 'CERTIFICATE' , 'KEY' , 'INTERMEDIATES' , 'ENABLE_SIGSTORE' , 'FULCIO' ,
594+ 'FULCIO_OIDC_CLIENT_ID' , 'FULCIO_OIDC_ISSUER' , 'FULCIO_TOKEN' ,
595+ 'TIMESTAMP_SERVERS' , 'TRACE' , 'SPIFFE_SOCKET' , 'PRODUCT_EXCLUDE_GLOB' ,
596+ 'PRODUCT_INCLUDE_GLOB' , 'ATTESTOR_LINK_EXPORT' , 'ATTESTOR_SBOM_EXPORT' ,
597+ 'ATTESTOR_SLSA_EXPORT' , 'ATTESTOR_MAVEN_POM_PATH' , 'EXTRA_ARGS'
598+ ] ;
599+
600+ if ( ! skipInputs . includes ( key . substring ( 6 ) ) ) {
601+ const inputName = key . substring ( 6 ) ; // Keep the case for setting
602+ core . info ( `Passing through input '${ inputName } ' to nested action` ) ;
603+ envVars [ key ] = process . env [ key ] ;
604+ }
605+ } ) ;
606+
607+ // For debugging, log all environment vars being passed to the nested action
608+ core . info ( `Passing these inputs to nested action Witness command:` ) ;
609+ Object . keys ( envVars )
610+ . filter ( key => key . startsWith ( 'INPUT_' ) )
611+ . forEach ( key => {
612+ core . info ( ` ${ key } =${ envVars [ key ] } ` ) ;
613+ } ) ;
614+
518615 // Build the witness run command
519616 const cmd = [ "run" ] ;
520617
@@ -757,7 +854,7 @@ async function runDirectCommandWithWitness(command, witnessOptions) {
757854 // Set up options for execution
758855 const execOptions = {
759856 cwd : process . env . GITHUB_WORKSPACE || process . cwd ( ) ,
760- env : process . env ,
857+ env : { ... process . env } , // Create a copy to avoid modifying the original
761858 listeners : {
762859 stdout : ( data ) => {
763860 process . stdout . write ( data . toString ( ) ) ;
@@ -768,6 +865,38 @@ async function runDirectCommandWithWitness(command, witnessOptions) {
768865 }
769866 } ;
770867
868+ // Process inputs with 'input-' prefix for direct commands
869+ const inputPrefix = 'input-' ;
870+ const nestedInputs = { } ;
871+
872+ // Get all inputs that start with 'input-'
873+ Object . keys ( process . env )
874+ . filter ( key => key . startsWith ( 'INPUT_' ) )
875+ . forEach ( key => {
876+ const inputName = key . substring ( 6 ) . toLowerCase ( ) ; // Remove 'INPUT_' prefix
877+ // Convert underscores in input name to hyphens for matching with input-prefix
878+ const normalizedInputName = inputName . replace ( / _ / g, '-' ) ;
879+
880+ if ( normalizedInputName . startsWith ( inputPrefix ) ) {
881+ const nestedInputName = normalizedInputName . substring ( inputPrefix . length ) ;
882+ nestedInputs [ nestedInputName ] = process . env [ key ] ;
883+ // Convert hyphens to underscores for environment variables
884+ const envName = nestedInputName . replace ( / - / g, '_' ) . toUpperCase ( ) ;
885+
886+ core . info ( `For direct command: Passing input '${ nestedInputName } ' from ${ inputName } ` ) ;
887+ // Set the environment variable for the nested command
888+ execOptions . env [ `INPUT_${ envName } ` ] = process . env [ key ] ;
889+ }
890+ } ) ;
891+
892+ // For debugging, log all inputs that will be passed to the command
893+ core . info ( `Direct command will have these inputs available:` ) ;
894+ Object . keys ( execOptions . env )
895+ . filter ( key => key . startsWith ( 'INPUT_' ) )
896+ . forEach ( key => {
897+ core . info ( ` ${ key } =${ execOptions . env [ key ] } ` ) ;
898+ } ) ;
899+
771900 // Execute and capture output
772901 let output = '' ;
773902
0 commit comments