Do not crash when parsing an invalid workflow file (#23972)
Fix #23658. Related to https://gitea.com/gitea/act/pulls/39
This commit is contained in:
parent
88033438aa
commit
ecf34fcd89
3 changed files with 13 additions and 3 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue