Handle non-string with inputs

This commit is contained in:
Henry Mercer 2022-12-08 18:36:05 +00:00
parent e67ad6aaed
commit a409f43c7a
3 changed files with 9 additions and 9 deletions

8
lib/workflow.js generated
View file

@ -264,7 +264,7 @@ function getStepsCallingAction(job, actionName) {
* determine that no such input is passed to the Action.
*/
function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
var _a;
var _a, _b;
const preamble = `Could not get ${inputName} input to ${actionName} since`;
if (!workflow.jobs) {
throw new Error(`${preamble} the workflow has no jobs.`);
@ -279,11 +279,11 @@ function getInputOrThrow(workflow, jobName, actionName, inputName, matrixVars) {
else if (stepsCallingAction.length > 1) {
throw new Error(`${preamble} the ${jobName} job calls ${actionName} multiple times.`);
}
let input = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName];
let input = (_b = (_a = stepsCallingAction[0].with) === null || _a === void 0 ? void 0 : _a[inputName]) === null || _b === void 0 ? void 0 : _b.toString();
if (input !== undefined && matrixVars !== undefined) {
// Make a basic attempt to substitute matrix variables
// First normalize by removing whitespace
// Normalize by removing whitespace
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
// Make a basic attempt to substitute matrix variables
for (const [key, value] of Object.entries(matrixVars)) {
input = input.replace(`\${{matrix.${key}}}`, value);
}

File diff suppressed because one or more lines are too long

View file

@ -11,7 +11,7 @@ export interface WorkflowJobStep {
name?: string;
run?: any;
uses?: string;
with?: { [key: string]: string };
with?: { [key: string]: boolean | number | string };
}
interface WorkflowJob {
@ -350,12 +350,12 @@ function getInputOrThrow(
);
}
let input = stepsCallingAction[0].with?.[inputName];
let input = stepsCallingAction[0].with?.[inputName]?.toString();
if (input !== undefined && matrixVars !== undefined) {
// Make a basic attempt to substitute matrix variables
// First normalize by removing whitespace
// Normalize by removing whitespace
input = input.replace(/\${{\s+/, "${{").replace(/\s+}}/, "}}");
// Make a basic attempt to substitute matrix variables
for (const [key, value] of Object.entries(matrixVars)) {
input = input.replace(`\${{matrix.${key}}}`, value);
}