aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authora1012112796 <1012112796@qq.com>2023-04-23 10:16:54 +0800
committerGitHub <noreply@github.com>2023-04-22 22:16:54 -0400
commit6bff6e3a1f21c6c1db95d5303bba2fca61d72202 (patch)
tree9aefe0c3395f809229bf57d7d91468abd8a292f5 /routers
parent136d7492ffb9e105364c542ae3ec9dcf7c4816a0 (diff)
downloadgitea-6bff6e3a1f21c6c1db95d5303bba2fca61d72202.tar.gz
gitea-6bff6e3a1f21c6c1db95d5303bba2fca61d72202.zip
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>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/view.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/routers/web/repo/view.go b/routers/web/repo/view.go
index 63e534fec0..f9dca91844 100644
--- a/routers/web/repo/view.go
+++ b/routers/web/repo/view.go
@@ -24,6 +24,7 @@ import (
repo_model "code.gitea.io/gitea/models/repo"
unit_model "code.gitea.io/gitea/models/unit"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/charset"
"code.gitea.io/gitea/modules/container"
@@ -39,6 +40,8 @@ import (
"code.gitea.io/gitea/modules/typesniffer"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/routers/web/feed"
+
+ "github.com/nektos/act/pkg/model"
)
const (
@@ -348,6 +351,15 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
if issueConfigErr != nil {
ctx.Data["FileError"] = strings.TrimSpace(issueConfigErr.Error())
}
+ } else if actions.IsWorkflow(ctx.Repo.TreePath) {
+ content, err := actions.GetContentFromEntry(entry)
+ if err != nil {
+ log.Error("actions.GetContentFromEntry: %v", err)
+ }
+ _, workFlowErr := model.ReadWorkflow(bytes.NewReader(content))
+ if workFlowErr != nil {
+ ctx.Data["FileError"] = ctx.Locale.Tr("actions.runs.invalid_workflow_helper", workFlowErr.Error())
+ }
}
isDisplayingSource := ctx.FormString("display") == "source"