diff --git a/act/jobparser/model.go b/act/jobparser/model.go index f63a0455..476853fd 100644 --- a/act/jobparser/model.go +++ b/act/jobparser/model.go @@ -260,7 +260,7 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) { } } case map[string]interface{}: - if k != "workflow_dispatch" || act != "inputs" { + if isInvalidOnType(k, act) { return nil, fmt.Errorf("unknown on type: %#v", v) } acts = nil @@ -304,6 +304,16 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) { } } +func isInvalidOnType(onType, subKey string) bool { + if onType == "workflow_dispatch" && subKey == "inputs" { + return false + } + if onType == "workflow_call" && (subKey == "inputs" || subKey == "outputs") { + return false + } + return true +} + // parseMappingNode parse a mapping node and preserve order. func parseMappingNode[T any](node *yaml.Node) ([]string, []T, error) { if node.Kind != yaml.MappingNode { diff --git a/act/jobparser/model_test.go b/act/jobparser/model_test.go index a034306f..45f8e9b2 100644 --- a/act/jobparser/model_test.go +++ b/act/jobparser/model_test.go @@ -163,7 +163,7 @@ func TestParseRawOn(t *testing.T) { }, }, { - input: "on: [pull_request, workflow_dispatch]", + input: "on: [pull_request, workflow_dispatch, workflow_call]", result: []*Event{ { Name: "pull_request", @@ -171,6 +171,9 @@ func TestParseRawOn(t *testing.T) { { Name: "workflow_dispatch", }, + { + Name: "workflow_call", + }, }, }, { @@ -194,6 +197,14 @@ func TestParseRawOn(t *testing.T) { }, }, }, + { + input: "on:\n workflow_call:\n inputs:\n test:\n type: string\n outputs:\n output:\n value: something", + result: []*Event{ + { + Name: "workflow_call", + }, + }, + }, } for _, kase := range kases { t.Run(kase.input, func(t *testing.T) {