Include workflow call inputs
This commit is contained in:
@@ -1,21 +1,29 @@
|
|||||||
import {data} from "@github/actions-expressions";
|
import {data} from "@github/actions-expressions";
|
||||||
|
import {InputConfig} from "@github/actions-workflow-parser/model/workflow-template";
|
||||||
import {WorkflowContext} from "../context/workflow-context";
|
import {WorkflowContext} from "../context/workflow-context";
|
||||||
|
|
||||||
export function getInputsContext(workflowContext: WorkflowContext): data.Dictionary {
|
export function getInputsContext(workflowContext: WorkflowContext): data.Dictionary {
|
||||||
const d = new data.Dictionary();
|
const d = new data.Dictionary();
|
||||||
if (!workflowContext?.template?.events) {
|
|
||||||
|
const events = workflowContext?.template?.events;
|
||||||
|
if (!events) {
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
const event = workflowContext.template.events["workflow_dispatch"];
|
const dispatch = events["workflow_dispatch"];
|
||||||
if (!event) {
|
if (dispatch?.inputs) {
|
||||||
return d;
|
addInputs(d, dispatch.inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputs = event.inputs;
|
const call = events["workflow_call"];
|
||||||
if (!inputs) {
|
if (call?.inputs) {
|
||||||
return d;
|
addInputs(d, call.inputs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return d;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addInputs(d: data.Dictionary, inputs: {[inputName: string]: InputConfig}) {
|
||||||
for (const inputName of Object.keys(inputs)) {
|
for (const inputName of Object.keys(inputs)) {
|
||||||
const input = inputs[inputName];
|
const input = inputs[inputName];
|
||||||
switch (input.type) {
|
switch (input.type) {
|
||||||
@@ -49,6 +57,4 @@ export function getInputsContext(workflowContext: WorkflowContext): data.Diction
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user