loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

show workflow config error on file view also (#24267)

As title, follow #24124


![image](https://user-images.githubusercontent.com/25342410/233763031-8c5ab4a1-a4db-4173-87f7-cef41860f1db.png)

---------

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

authored by

a1012112796
wxiaoguang
and committed by
GitHub
6bff6e3a 136d7492

+20
+8
modules/actions/workflows.go
··· 29 29 } 30 30 } 31 31 32 + func IsWorkflow(path string) bool { 33 + if (!strings.HasSuffix(path, ".yaml")) && (!strings.HasSuffix(path, ".yml")) { 34 + return false 35 + } 36 + 37 + return strings.HasPrefix(path, ".gitea/workflows") || strings.HasPrefix(path, ".github/workflows") 38 + } 39 + 32 40 func ListWorkflows(commit *git.Commit) (git.Entries, error) { 33 41 tree, err := commit.SubTree(".gitea/workflows") 34 42 if _, ok := err.(git.ErrNotExist); ok {
+12
routers/web/repo/view.go
··· 24 24 repo_model "code.gitea.io/gitea/models/repo" 25 25 unit_model "code.gitea.io/gitea/models/unit" 26 26 user_model "code.gitea.io/gitea/models/user" 27 + "code.gitea.io/gitea/modules/actions" 27 28 "code.gitea.io/gitea/modules/base" 28 29 "code.gitea.io/gitea/modules/charset" 29 30 "code.gitea.io/gitea/modules/container" ··· 39 40 "code.gitea.io/gitea/modules/typesniffer" 40 41 "code.gitea.io/gitea/modules/util" 41 42 "code.gitea.io/gitea/routers/web/feed" 43 + 44 + "github.com/nektos/act/pkg/model" 42 45 ) 43 46 44 47 const ( ··· 347 350 _, issueConfigErr := ctx.Repo.GetIssueConfig(ctx.Repo.TreePath, ctx.Repo.Commit) 348 351 if issueConfigErr != nil { 349 352 ctx.Data["FileError"] = strings.TrimSpace(issueConfigErr.Error()) 353 + } 354 + } else if actions.IsWorkflow(ctx.Repo.TreePath) { 355 + content, err := actions.GetContentFromEntry(entry) 356 + if err != nil { 357 + log.Error("actions.GetContentFromEntry: %v", err) 358 + } 359 + _, workFlowErr := model.ReadWorkflow(bytes.NewReader(content)) 360 + if workFlowErr != nil { 361 + ctx.Data["FileError"] = ctx.Locale.Tr("actions.runs.invalid_workflow_helper", workFlowErr.Error()) 350 362 } 351 363 } 352 364