0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-22 05:42:16 +02:00

fix merge

This commit is contained in:
wxiaoguang 2025-07-09 10:39:50 +08:00
parent 9da6b36646
commit 2fa624a32e
5 changed files with 27 additions and 7 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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

View File

@ -14,7 +14,7 @@
<ul style="list-style: none; padding: 0; margin: 0 0 30px 0;">
{{range $job := .Jobs}}
<li style="background-color: #ffffff; border: 1px solid #ddd; border-radius: 6px; padding: 12px 16px; margin-bottom: 10px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05); transition: box-shadow 0.2s ease;">
<a href="{{$job.HTMLURL}}" style="color: #0073e6; text-decoration: none; font-weight: bold;" onmouseover="this.style.textDecoration='underline'" onmouseout="this.style.textDecoration='none'">
<a href="{{$job.HTMLURL}}" style="color: #0073e6; text-decoration: none; font-weight: bold;">
{{$job.Status}}: {{$job.Name}}{{if gt $job.Attempt 1}}, Attempt #{{$job.Attempt}}{{end}}
</a>
</li>
@ -24,7 +24,7 @@
<br/>
<div style="text-align: center; margin-top: 30px;">
<a href="{{.Run.HTMLURL}}" style="display: inline-block; background-color: #28a745; color: #ffffff !important; text-decoration: none; padding: 10px 20px; border-radius: 5px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: background-color 0.3s ease;" onmouseover="this.style.backgroundColor='#218838'" onmouseout="this.style.backgroundColor='#28a745'">
<a href="{{.Run.HTMLURL}}" style="display: inline-block; background-color: #28a745; color: #ffffff !important; text-decoration: none; padding: 10px 20px; border-radius: 5px; font-weight: bold; box-shadow: 0 2px 4px rgba(0,0,0,0.1); transition: background-color 0.3s ease;">
{{.locale.Tr "mail.view_it_on" AppName}}
</a>
</div>