Skip to content

Commit 37fa025

Browse files
committed
Fix input forwarding for nested actions
- Added enhanced debugging for WHO_TO_GREET input - Implemented fallback mechanisms to ensure input is properly passed - Added robust error reporting to identify input sources - Fixed environment variable propagation to nested actions
1 parent a81a02d commit 37fa025

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed

index.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,21 @@ async function runActionWithWitness(actionDir, witnessOptions) {
603603
envVars[key] = process.env[key];
604604
}
605605
});
606+
607+
// Explicitly handle WHO_TO_GREET which is required for the hello-world action
608+
const inputWhoToGreet = process.env['INPUT_INPUT_WHO_TO_GREET'];
609+
if (inputWhoToGreet) {
610+
core.info(`🔍 Explicitly setting WHO_TO_GREET from INPUT_INPUT_WHO_TO_GREET: ${inputWhoToGreet}`);
611+
envVars['INPUT_WHO_TO_GREET'] = inputWhoToGreet;
612+
} else {
613+
core.warning(`🔍 No INPUT_INPUT_WHO_TO_GREET found - checking for variants...`);
614+
// Let's check for case variants
615+
Object.keys(process.env)
616+
.filter(key => key.toLowerCase().includes('who') && key.toLowerCase().includes('greet'))
617+
.forEach(key => {
618+
core.warning(` Found key ${key}=${process.env[key]}`);
619+
});
620+
}
606621

607622
// For debugging, log all environment vars being passed to the nested action
608623
core.info(`Passing these inputs to nested action Witness command:`);
@@ -611,6 +626,19 @@ async function runActionWithWitness(actionDir, witnessOptions) {
611626
.forEach(key => {
612627
core.info(` ${key}=${envVars[key]}`);
613628
});
629+
630+
// Debug specifically the who-to-greet input which is required for hello-world action
631+
if (envVars['INPUT_WHO_TO_GREET']) {
632+
core.info(`✅ Found required input WHO_TO_GREET = ${envVars['INPUT_WHO_TO_GREET']}`);
633+
} else {
634+
core.warning(`❌ Required input WHO_TO_GREET not found in environment variables!`);
635+
// Display all available input-* variables for debugging
636+
Object.keys(process.env)
637+
.filter(key => key.startsWith('INPUT_') && key.includes('WHO_TO_GREET'))
638+
.forEach(key => {
639+
core.warning(` Found similar input: ${key}=${process.env[key]}`);
640+
});
641+
}
614642

615643
// Build the witness run command
616644
const cmd = ["run"];
@@ -689,6 +717,20 @@ async function runActionWithWitness(actionDir, witnessOptions) {
689717

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

720+
// Verify we have the required inputs for hello-world action
721+
if (envVars['INPUT_WHO_TO_GREET']) {
722+
core.info(`✓ Found WHO_TO_GREET in envVars before exec: ${envVars['INPUT_WHO_TO_GREET']}`);
723+
} else {
724+
core.warning(`⚠️ WHO_TO_GREET missing from envVars - adding it from explicit source`);
725+
const whoToGreet = process.env['INPUT_INPUT_WHO_TO_GREET'] || process.env['INPUT_WHO_TO_GREET'];
726+
if (whoToGreet) {
727+
envVars['INPUT_WHO_TO_GREET'] = whoToGreet;
728+
core.info(`✓ Set INPUT_WHO_TO_GREET=${whoToGreet} from explicit source`);
729+
} else {
730+
core.error(`❌ Failed to find who-to-greet input in any form!`);
731+
}
732+
}
733+
692734
// Set up options for execution
693735
const execOptions = {
694736
cwd: actionDir,
@@ -889,13 +931,48 @@ async function runDirectCommandWithWitness(command, witnessOptions) {
889931
}
890932
});
891933

934+
// Explicitly handle WHO_TO_GREET which is required for the hello-world action
935+
const inputWhoToGreet = process.env['INPUT_INPUT_WHO_TO_GREET'];
936+
if (inputWhoToGreet) {
937+
core.info(`🔍 For direct command: Explicitly setting WHO_TO_GREET from INPUT_INPUT_WHO_TO_GREET: ${inputWhoToGreet}`);
938+
execOptions.env['INPUT_WHO_TO_GREET'] = inputWhoToGreet;
939+
} else {
940+
core.warning(`🔍 For direct command: No INPUT_INPUT_WHO_TO_GREET found - checking for variants...`);
941+
// Let's check for case variants
942+
Object.keys(process.env)
943+
.filter(key => key.toLowerCase().includes('who') && key.toLowerCase().includes('greet'))
944+
.forEach(key => {
945+
core.warning(` Found key ${key}=${process.env[key]}`);
946+
});
947+
}
948+
892949
// For debugging, log all inputs that will be passed to the command
893950
core.info(`Direct command will have these inputs available:`);
894951
Object.keys(execOptions.env)
895952
.filter(key => key.startsWith('INPUT_'))
896953
.forEach(key => {
897954
core.info(` ${key}=${execOptions.env[key]}`);
898955
});
956+
957+
// Debug specifically the who-to-greet input which is required for hello-world action
958+
if (execOptions.env['INPUT_WHO_TO_GREET']) {
959+
core.info(`✅ For direct command: Found required input WHO_TO_GREET = ${execOptions.env['INPUT_WHO_TO_GREET']}`);
960+
} else {
961+
core.warning(`⚠️ For direct command: WHO_TO_GREET missing from envVars - adding it from explicit source`);
962+
const whoToGreet = process.env['INPUT_INPUT_WHO_TO_GREET'] || process.env['INPUT_WHO_TO_GREET'];
963+
if (whoToGreet) {
964+
execOptions.env['INPUT_WHO_TO_GREET'] = whoToGreet;
965+
core.info(`✓ Set INPUT_WHO_TO_GREET=${whoToGreet} from explicit source`);
966+
} else {
967+
core.error(`❌ Failed to find who-to-greet input in any form!`);
968+
// Display all available input-* variables for debugging
969+
Object.keys(process.env)
970+
.filter(key => key.startsWith('INPUT_') && key.includes('WHO'))
971+
.forEach(key => {
972+
core.warning(` Found similar input: ${key}=${process.env[key]}`);
973+
});
974+
}
975+
}
899976

900977
// Execute and capture output
901978
let output = '';

0 commit comments

Comments
 (0)