From 5da4954b6578b55d7266ae0de4cb4e6eba0a8710 Mon Sep 17 00:00:00 2001 From: "Guillaume S." Date: Wed, 26 Feb 2025 06:19:02 +0000 Subject: [PATCH] fix handle missing yaml.ScalarNode (#129) This bug was reported on https://github.com/go-gitea/gitea/issues/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 Co-authored-by: Guillaume S. Co-committed-by: Guillaume S. --- pkg/jobparser/model.go | 7 +++++++ pkg/jobparser/model_test.go | 13 +++++++++++++ 2 files changed, 20 insertions(+) diff --git a/pkg/jobparser/model.go b/pkg/jobparser/model.go index 6f4ea27..e823bca 100644 --- a/pkg/jobparser/model.go +++ b/pkg/jobparser/model.go @@ -405,6 +405,13 @@ func ParseRawOn(rawOn *yaml.Node) ([]*Event, error) { return nil, err } acts[act] = t + case yaml.ScalarNode: + var t string + err := content.Decode(&t) + if err != nil { + return nil, err + } + acts[act] = []string{t} case yaml.MappingNode: if k != "workflow_dispatch" || act != "inputs" { return nil, fmt.Errorf("map should only for workflow_dispatch but %s: %#v", act, content) diff --git a/pkg/jobparser/model_test.go b/pkg/jobparser/model_test.go index 009ef15..079c32d 100644 --- a/pkg/jobparser/model_test.go +++ b/pkg/jobparser/model_test.go @@ -58,6 +58,19 @@ func TestParseRawOn(t *testing.T) { }, }, }, + { + input: "on:\n push:\n branches: main", + result: []*Event{ + { + Name: "push", + acts: map[string][]string{ + "branches": { + "main", + }, + }, + }, + }, + }, { input: "on:\n branch_protection_rule:\n types: [created, deleted]", result: []*Event{