From 3daf3132057d33bee325857b016a60db332fd050 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Sat, 25 Mar 2023 12:13:50 +0800 Subject: [PATCH] chore(yaml): Improve `ParseRawOn` (#28) See [act_runner #71 comment](https://gitea.com/gitea/act_runner/issues/71#issuecomment-733806), we need to handle `nil interface{}` in `ParseRawOn` function Co-authored-by: Lunny Xiao Reviewed-on: https://gitea.com/gitea/act/pulls/28 Reviewed-by: Lunny Xiao Reviewed-by: appleboy Co-authored-by: Zettat123 Co-committed-by: Zettat123 --- pkg/jobparser/model.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/jobparser/model.go b/pkg/jobparser/model.go index a0bc61a..f9c94ec 100644 --- a/pkg/jobparser/model.go +++ b/pkg/jobparser/model.go @@ -177,6 +177,13 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) { } res := make([]*Event, 0, len(val)) for k, v := range val { + if v == nil { + res = append(res, &Event{ + Name: k, + Acts: map[string][]string{}, + }) + continue + } switch t := v.(type) { case string: res = append(res, &Event{