aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-03-14 16:27:03 +0900
committerGitHub <noreply@github.com>2023-03-14 15:27:03 +0800
commitaac07d010f261c00fb3bd9644c71dc108c668c11 (patch)
tree1270a43ca5eec3c2cb392f63788250e755a37e36 /routers/web
parent6ff5400af91aefb02cbc7dd59f6be23cc2bf7865 (diff)
downloadgitea-aac07d010f261c00fb3bd9644c71dc108c668c11.tar.gz
gitea-aac07d010f261c00fb3bd9644c71dc108c668c11.zip
Add workflow error notification in ui (#23404)
![image](https://user-images.githubusercontent.com/18380374/224237847-07a30029-32d4-4af7-a36e-e55f0ed899aa.png) ![image](https://user-images.githubusercontent.com/18380374/224239309-a96120e1-5eec-41c0-89aa-9cf63d1df30c.png) --------- Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Diffstat (limited to 'routers/web')
-rw-r--r--routers/web/repo/actions/actions.go26
1 files changed, 23 insertions, 3 deletions
diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go
index 0e7a95ed07..dd2dc55bd5 100644
--- a/routers/web/repo/actions/actions.go
+++ b/routers/web/repo/actions/actions.go
@@ -23,6 +23,12 @@ const (
tplViewActions base.TplName = "repo/actions/view"
)
+type Workflow struct {
+ Entry git.TreeEntry
+ IsInvalid bool
+ ErrMsg string
+}
+
// MustEnableActions check if actions are enabled in settings
func MustEnableActions(ctx *context.Context) {
if !setting.Actions.Enabled {
@@ -47,7 +53,7 @@ func List(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("actions.actions")
ctx.Data["PageIsActions"] = true
- var workflows git.Entries
+ var workflows []Workflow
if empty, err := ctx.Repo.GitRepo.IsEmpty(); err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
@@ -62,13 +68,27 @@ func List(ctx *context.Context) {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}
- workflows, err = actions.ListWorkflows(commit)
+ entries, err := actions.ListWorkflows(commit)
if err != nil {
ctx.Error(http.StatusInternalServerError, err.Error())
return
}
+ workflows = make([]Workflow, 0, len(entries))
+ for _, entry := range entries {
+ workflow := Workflow{Entry: *entry}
+ content, err := actions.GetContentFromEntry(entry)
+ if err != nil {
+ ctx.Error(http.StatusInternalServerError, err.Error())
+ return
+ }
+ _, err = actions.GetEventsFromContent(content)
+ if err != nil {
+ workflow.IsInvalid = true
+ workflow.ErrMsg = err.Error()
+ }
+ workflows = append(workflows, workflow)
+ }
}
-
ctx.Data["workflows"] = workflows
ctx.Data["RepoLink"] = ctx.Repo.Repository.Link()