mirror of
https://github.com/go-gitea/gitea.git
synced 2025-09-21 20:45:35 +00:00
UPDATE
This commit is contained in:
@@ -550,6 +550,14 @@ repo.transfer.body = To accept or reject it visit %s or just ignore it.
|
|||||||
repo.collaborator.added.subject = %s added you to %s
|
repo.collaborator.added.subject = %s added you to %s
|
||||||
repo.collaborator.added.text = You have been added as a collaborator of repository:
|
repo.collaborator.added.text = You have been added as a collaborator of repository:
|
||||||
|
|
||||||
|
repo.actions.run.failed = Run failed
|
||||||
|
repo.actions.run.succeeded = Run succeeded
|
||||||
|
repo.actions.run.cancelled = Run cancelled
|
||||||
|
repo.actions.jobs.all_succeeded = All jobs have succeeded
|
||||||
|
repo.actions.jobs.all_failed = All jobs have failed
|
||||||
|
repo.actions.jobs.some_not_successful = Some jobs were not successful
|
||||||
|
repo.actions.jobs.all_cancelled = All jobs have been cancelled
|
||||||
|
|
||||||
team_invite.subject = %[1]s has invited you to join the %[2]s organization
|
team_invite.subject = %[1]s has invited you to join the %[2]s organization
|
||||||
team_invite.text_1 = %[1]s has invited you to join team %[2]s in organization %[3]s.
|
team_invite.text_1 = %[1]s has invited you to join team %[2]s in organization %[3]s.
|
||||||
team_invite.text_2 = Please click the following link to join the team:
|
team_invite.text_2 = Please click the following link to join the team:
|
||||||
|
@@ -8,6 +8,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
"time"
|
||||||
|
|
||||||
actions_model "code.gitea.io/gitea/models/actions"
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@@ -24,10 +25,11 @@ import (
|
|||||||
const tplWorkflowRun templates.TplName = "repo/actions/workflow_run"
|
const tplWorkflowRun templates.TplName = "repo/actions/workflow_run"
|
||||||
|
|
||||||
type convertedWorkflowJob struct {
|
type convertedWorkflowJob struct {
|
||||||
HTMLURL string
|
HTMLURL string
|
||||||
Status actions_model.Status
|
Name string
|
||||||
Name string
|
Status actions_model.Status
|
||||||
Attempt int64
|
Attempt int64
|
||||||
|
Duration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateMessageIDForActionsWorkflowRunStatusEmail(repo *repo_model.Repository, run *actions_model.ActionRun) string {
|
func generateMessageIDForActionsWorkflowRunStatusEmail(repo *repo_model.Repository, run *actions_model.ActionRun) string {
|
||||||
@@ -35,16 +37,15 @@ func generateMessageIDForActionsWorkflowRunStatusEmail(repo *repo_model.Reposito
|
|||||||
}
|
}
|
||||||
|
|
||||||
func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, sender *user_model.User, recipients []*user_model.User) {
|
func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo_model.Repository, run *actions_model.ActionRun, sender *user_model.User, recipients []*user_model.User) {
|
||||||
subject := "Run"
|
var subjectTrString string
|
||||||
switch run.Status {
|
switch run.Status {
|
||||||
case actions_model.StatusFailure:
|
case actions_model.StatusFailure:
|
||||||
subject += " failed"
|
subjectTrString = "mail.repo.actions.run.failed"
|
||||||
case actions_model.StatusCancelled:
|
case actions_model.StatusCancelled:
|
||||||
subject += " cancelled"
|
subjectTrString = "mail.repo.actions.run.cancelled"
|
||||||
case actions_model.StatusSuccess:
|
case actions_model.StatusSuccess:
|
||||||
subject += " succeeded"
|
subjectTrString = "mail.repo.actions.run.succeeded"
|
||||||
}
|
}
|
||||||
subject = fmt.Sprintf("%s: %s (%s)", subject, run.WorkflowID, base.ShortSha(run.CommitSHA))
|
|
||||||
displayName := fromDisplayName(sender)
|
displayName := fromDisplayName(sender)
|
||||||
messageID := generateMessageIDForActionsWorkflowRunStatusEmail(repo, run)
|
messageID := generateMessageIDForActionsWorkflowRunStatusEmail(repo, run)
|
||||||
metadataHeaders := generateMetadataHeaders(repo)
|
metadataHeaders := generateMetadataHeaders(repo)
|
||||||
@@ -75,10 +76,11 @@ func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
convertedJobs = append(convertedJobs, convertedWorkflowJob{
|
convertedJobs = append(convertedJobs, convertedWorkflowJob{
|
||||||
HTMLURL: converted0.HTMLURL,
|
HTMLURL: converted0.HTMLURL,
|
||||||
Name: converted0.Name,
|
Name: converted0.Name,
|
||||||
Status: job.Status,
|
Status: job.Status,
|
||||||
Attempt: converted0.RunAttempt,
|
Attempt: converted0.RunAttempt,
|
||||||
|
Duration: job.Duration(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,27 +90,28 @@ func composeAndSendActionsWorkflowRunStatusEmail(ctx context.Context, repo *repo
|
|||||||
}
|
}
|
||||||
for lang, tos := range langMap {
|
for lang, tos := range langMap {
|
||||||
locale := translation.NewLocale(lang)
|
locale := translation.NewLocale(lang)
|
||||||
var runStatusText string
|
var runStatusTrString string
|
||||||
switch run.Status {
|
switch run.Status {
|
||||||
case actions_model.StatusSuccess:
|
case actions_model.StatusSuccess:
|
||||||
runStatusText = "All jobs have succeeded"
|
runStatusTrString = "mail.repo.actions.jobs.all_succeeded"
|
||||||
case actions_model.StatusFailure:
|
case actions_model.StatusFailure:
|
||||||
runStatusText = "All jobs have failed"
|
runStatusTrString = "mail.repo.actions.jobs.all_failed"
|
||||||
for _, job := range jobs {
|
for _, job := range jobs {
|
||||||
if !job.Status.IsFailure() {
|
if !job.Status.IsFailure() {
|
||||||
runStatusText = "Some jobs were not successful"
|
runStatusTrString = "mail.repo.actions.jobs.some_not_successful"
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case actions_model.StatusCancelled:
|
case actions_model.StatusCancelled:
|
||||||
runStatusText = "All jobs have been cancelled"
|
runStatusTrString = "mail.repo.actions.jobs.all_cancelled"
|
||||||
}
|
}
|
||||||
|
subject := fmt.Sprintf("%s: %s (%s)", locale.TrString(subjectTrString), run.WorkflowID, base.ShortSha(run.CommitSHA))
|
||||||
var mailBody bytes.Buffer
|
var mailBody bytes.Buffer
|
||||||
if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, string(tplWorkflowRun), map[string]any{
|
if err := LoadedTemplates().BodyTemplates.ExecuteTemplate(&mailBody, string(tplWorkflowRun), map[string]any{
|
||||||
"Subject": subject,
|
"Subject": subject,
|
||||||
"Repo": repo,
|
"Repo": repo,
|
||||||
"Run": run,
|
"Run": run,
|
||||||
"RunStatusText": runStatusText,
|
"RunStatusText": locale.TrString(runStatusTrString),
|
||||||
"Jobs": convertedJobs,
|
"Jobs": convertedJobs,
|
||||||
"locale": locale,
|
"locale": locale,
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
@@ -12,7 +12,9 @@ Jobs:
|
|||||||
Status: success
|
Status: success
|
||||||
Attempt: 1
|
Attempt: 1
|
||||||
HTMLURL: http://localhost/job/1
|
HTMLURL: http://localhost/job/1
|
||||||
|
Duration: 1h2m3s
|
||||||
- Name: Job-Name-2
|
- Name: Job-Name-2
|
||||||
Status: failure
|
Status: failure
|
||||||
Attempt: 2
|
Attempt: 2
|
||||||
HTMLURL: http://localhost/job/2
|
HTMLURL: http://localhost/job/2
|
||||||
|
Duration: 1h2m3s
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
{{range $job := .Jobs}}
|
{{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;">
|
<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;">
|
<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}}
|
{{$job.Status}}: {{$job.Name}}{{if gt $job.Attempt 1}}, Attempt #{{$job.Attempt}}{{end}}, {{$job.Duration}}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
Reference in New Issue
Block a user