Skip to content

Commit 7b4a230

Browse files
committed
update text and colors of non gitea webhooks
1 parent 0c3b0fc commit 7b4a230

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

services/webhook/general.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,29 @@ func getStatusPayloadInfo(p *api.CommitStatusPayload, linkFormatter linkFormatte
326326
}
327327

328328
func getWorkflowJobPayloadInfo(p *api.WorkflowJobPayload, linkFormatter linkFormatter, withSender bool) (text string, color int) {
329-
refLink := linkFormatter(p.WorkflowJob.HTMLURL, fmt.Sprintf("%s(#%d)", p.WorkflowJob.Name, p.WorkflowJob.RunID)+"["+p.WorkflowJob.HeadSha+"]:"+p.WorkflowJob.Conclusion)
329+
description := p.WorkflowJob.Conclusion
330+
if description == "" {
331+
description = p.WorkflowJob.Status
332+
}
333+
refLink := linkFormatter(p.WorkflowJob.HTMLURL, fmt.Sprintf("%s(#%d)", p.WorkflowJob.Name, p.WorkflowJob.RunID)+"["+base.ShortSha(p.WorkflowJob.HeadSha)+"]:"+description)
330334

331335
text = fmt.Sprintf("Workflow Job %s: %s", p.Action, refLink)
332-
color = greenColor
336+
switch description {
337+
case "waiting":
338+
color = orangeColor
339+
case "queued":
340+
color = orangeColorLight
341+
case "success":
342+
color = greenColor
343+
case "failure":
344+
color = redColor
345+
case "cancelled":
346+
color = yellowColor
347+
case "skipped":
348+
color = purpleColor
349+
default:
350+
color = greyColor
351+
}
333352
if withSender {
334353
text += fmt.Sprintf(" by %s", linkFormatter(setting.AppURL+url.PathEscape(p.Sender.UserName), p.Sender.UserName))
335354
}

0 commit comments

Comments
 (0)