Skip to content

Commit 5da4954

Browse files
gsvdlunny
authored andcommitted
fix handle missing yaml.ScalarNode (#129)
This bug was reported on go-gitea/gitea#33657 Rewrite of (see below) was missing in this commit https://gitea.com/gsvd/act/commit/6cdf1e5788dbfa8fe9787a07178c28b64837a61f ```go case string: acts[act] = []string{b} ``` Reviewed-on: https://gitea.com/gitea/act/pulls/129 Reviewed-by: Lunny Xiao <[email protected]> Co-authored-by: Guillaume S. <[email protected]> Co-committed-by: Guillaume S. <[email protected]>
1 parent ec091ad commit 5da4954

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

pkg/jobparser/model.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,13 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) {
405405
return nil, err
406406
}
407407
acts[act] = t
408+
case yaml.ScalarNode:
409+
var t string
410+
err := content.Decode(&t)
411+
if err != nil {
412+
return nil, err
413+
}
414+
acts[act] = []string{t}
408415
case yaml.MappingNode:
409416
if k != "workflow_dispatch" || act != "inputs" {
410417
return nil, fmt.Errorf("map should only for workflow_dispatch but %s: %#v", act, content)

pkg/jobparser/model_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ func TestParseRawOn(t *testing.T) {
5858
},
5959
},
6060
},
61+
{
62+
input: "on:\n push:\n branches: main",
63+
result: []*Event{
64+
{
65+
Name: "push",
66+
acts: map[string][]string{
67+
"branches": {
68+
"main",
69+
},
70+
},
71+
},
72+
},
73+
},
6174
{
6275
input: "on:\n branch_protection_rule:\n types: [created, deleted]",
6376
result: []*Event{

0 commit comments

Comments
 (0)