Create alternate logic branch for workflow-call
This commit is contained in:
@@ -59,29 +59,26 @@ export function convertOn(context: TemplateContext, token: TemplateToken): Event
|
||||
|
||||
// All other events are defined as mappings. During schema validation we already ensure that events
|
||||
// receive only known keys, so here we can focus on the values and whether they are valid.
|
||||
|
||||
const eventToken = item.value.assertMapping(`event ${eventName}`);
|
||||
if(eventName === "workflow_call") {
|
||||
result[eventName] = {
|
||||
...convertPatternFilter("branches", eventToken),
|
||||
...convertPatternFilter("tags", eventToken),
|
||||
...convertPatternFilter("paths", eventToken),
|
||||
...convertFilter("types", eventToken),
|
||||
...convertFilter("workflows", eventToken),
|
||||
...convertEventWorkflowCall(context, eventToken)
|
||||
};
|
||||
}else{
|
||||
result[eventName] = {
|
||||
...convertPatternFilter("branches", eventToken),
|
||||
...convertPatternFilter("tags", eventToken),
|
||||
...convertPatternFilter("paths", eventToken),
|
||||
...convertFilter("types", eventToken),
|
||||
...convertFilter("workflows", eventToken),
|
||||
...convertEventWorkflowDispatchInputs(context, eventToken),
|
||||
};
|
||||
if (eventName === "workflow_call") {
|
||||
result.workflow_call = convertEventWorkflowCall(context, eventToken);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (eventName === "workflow_dispatch") {
|
||||
result.workflow_dispatch = convertEventWorkflowDispatchInputs(context, eventToken);
|
||||
continue;
|
||||
}
|
||||
|
||||
result[eventName] = {
|
||||
...convertPatternFilter("branches", eventToken),
|
||||
...convertPatternFilter("tags", eventToken),
|
||||
...convertPatternFilter("paths", eventToken),
|
||||
...convertFilter("types", eventToken),
|
||||
...convertFilter("workflows", eventToken)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {TemplateContext} from "../../templates/template-context";
|
||||
import {MappingToken, TemplateToken} from "../../templates/tokens";
|
||||
import {isMapping} from "../../templates/tokens/type-guards";
|
||||
import {SecretConfig, WorkflowCallConfig, InputConfig,InputType} from "../workflow-template";
|
||||
import {SecretConfig, WorkflowCallConfig, InputConfig, InputType} from "../workflow-template";
|
||||
import {convertStringList} from "./string-list";
|
||||
import {ScalarToken} from "../../templates/tokens/scalar-token";
|
||||
|
||||
@@ -29,7 +29,6 @@ export function convertEventWorkflowCall(context: TemplateContext, token: Mappin
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
export function convertWorkflowInputs(
|
||||
context: TemplateContext,
|
||||
token: MappingToken
|
||||
@@ -85,7 +84,7 @@ export function convertWorkflowInput(context: TemplateContext, token: MappingTok
|
||||
}
|
||||
|
||||
// Validate default value
|
||||
if (defaultValue !== undefined) {
|
||||
if (defaultValue !== undefined && !defaultValue.isExpression) {
|
||||
try {
|
||||
switch (result.type) {
|
||||
case InputType.boolean:
|
||||
|
||||
@@ -158,7 +158,7 @@ export type WorkflowDispatchConfig = {
|
||||
};
|
||||
|
||||
export type WorkflowCallConfig = {
|
||||
inputs?: {[inputName: string]: InputConfig};
|
||||
inputs?: {[inputName: string]: InputConfig & {default?: string | boolean | number | ScalarToken}};
|
||||
secrets?: {[secretName: string]: SecretConfig};
|
||||
// TODO - these are supported in C# and Go but not in TS yet
|
||||
// outputs: { [outputName: string]: OutputConfig }
|
||||
|
||||
Reference in New Issue
Block a user