diff --git a/routers/web/devtest/mail_preview.go b/routers/web/devtest/mail_preview.go index 79dd441eab..d6bade15d7 100644 --- a/routers/web/devtest/mail_preview.go +++ b/routers/web/devtest/mail_preview.go @@ -16,7 +16,7 @@ import ( func MailPreviewRender(ctx *context.Context) { tmplName := ctx.PathParam("*") - mockDataContent, err := templates.AssetFS().ReadFile("mail/" + tmplName + ".mock.yml") + mockDataContent, err := templates.AssetFS().ReadFile("mail/" + tmplName + ".devtest.yml") mockData := map[string]any{} if err == nil { err = yaml.Unmarshal(mockDataContent, &mockData) diff --git a/services/mailer/mail_workflow_run.go b/services/mailer/mail_workflow_run.go index 8f642302aa..d57784cfca 100644 --- a/services/mailer/mail_workflow_run.go +++ b/services/mailer/mail_workflow_run.go @@ -54,9 +54,11 @@ func sendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Rep return } sort.SliceStable(jobs, func(i, j int) bool { - si := jobs[i].Status - sj := jobs[j].Status - return !(si == sj || si.IsSuccess()) && si < sj + si, sj := jobs[i].Status, jobs[j].Status + if si != sj || sj.IsSuccess() /* if not equal, then success is the max */ { + return true + } + return si < sj }) convertedJobs := make([]convertedWorkflowJob, 0, len(jobs)) @@ -96,7 +98,7 @@ func sendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Rep runStatusText = "All jobs have been cancelled" } var mailBody bytes.Buffer - if err := bodyTemplates.ExecuteTemplate(&mailBody, tplWorkflowRun, map[string]any{ + if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, tplWorkflowRun, map[string]any{ "Subject": subject, "Repo": repo, "Run": run, diff --git a/templates/mail/auth/activate.mock.yml b/templates/mail/auth/activate.devtest.yml similarity index 100% rename from templates/mail/auth/activate.mock.yml rename to templates/mail/auth/activate.devtest.yml diff --git a/templates/mail/notify/workflow_run.devtest.yml b/templates/mail/notify/workflow_run.devtest.yml new file mode 100644 index 0000000000..1e285be328 --- /dev/null +++ b/templates/mail/notify/workflow_run.devtest.yml @@ -0,0 +1,18 @@ +RunStatusText: run status text .... + +Repo: + FullName: RepoName + +Run: + WorkflowID: WorkflowID + HTMLURL: http://localhost/run/1 + +Jobs: + - Name: Job-Name-1 + Status: success + Attempt: 1 + HTMLURL: http://localhost/job/1 + - Name: Job-Name-2 + Status: failed + Attempt: 2 + HTMLURL: http://localhost/job/2 diff --git a/templates/mail/notify/workflow_run.tmpl b/templates/mail/notify/workflow_run.tmpl index 3b76d61107..f6dd8ad510 100644 --- a/templates/mail/notify/workflow_run.tmpl +++ b/templates/mail/notify/workflow_run.tmpl @@ -14,7 +14,7 @@