summaryrefslogtreecommitdiffstats
path: root/modules/actions
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-04-07 20:12:10 +0800
committerGitHub <noreply@github.com>2023-04-07 20:12:10 +0800
commitecf34fcd899fecad9782eea3097a4c38f9fe258b (patch)
treea83daec1574cc96fdba52033da6b9b632fc0c7cf /modules/actions
parent88033438aa8214569913899a17b19b57bd609d97 (diff)
downloadgitea-ecf34fcd899fecad9782eea3097a4c38f9fe258b.tar.gz
gitea-ecf34fcd899fecad9782eea3097a4c38f9fe258b.zip
Do not crash when parsing an invalid workflow file (#23972)
Fix #23658. Related to https://gitea.com/gitea/act/pulls/39
Diffstat (limited to 'modules/actions')
-rw-r--r--modules/actions/workflows.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/modules/actions/workflows.go b/modules/actions/workflows.go
index 76c144bb2b..d30982a46b 100644
--- a/modules/actions/workflows.go
+++ b/modules/actions/workflows.go
@@ -17,8 +17,18 @@ import (
"github.com/nektos/act/pkg/jobparser"
"github.com/nektos/act/pkg/model"
"github.com/nektos/act/pkg/workflowpattern"
+ "gopkg.in/yaml.v3"
)
+func init() {
+ model.OnDecodeNodeError = func(node yaml.Node, out interface{}, err error) {
+ // Log the error instead of panic or fatal.
+ // It will be a big job to refactor act/pkg/model to return decode error,
+ // so we just log the error and return empty value, and improve it later.
+ log.Error("Failed to decode node %v into %T: %v", node, out, err)
+ }
+}
+
func ListWorkflows(commit *git.Commit) (git.Entries, error) {
tree, err := commit.SubTree(".gitea/workflows")
if _, ok := err.(git.ErrNotExist); ok {