feat(webhook): add workflow_step webhook events for step-level CI notifications
Adds HookEventWorkflowStep event type that fires on every step state transition (queued -> in_progress -> completed). Follows the same pattern as the existing workflow_job events. - New WorkflowStepPayload struct with run/job/step context - WorkflowStepStatusUpdate notifier interface + dispatch - Step state change detection in UpdateTask runner endpoint - Fix: register workflow_step in updateHookEvents API mapping - Full test coverage mirroring workflow_job tests Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -389,6 +389,37 @@ func getWorkflowJobPayloadInfo(p *api.WorkflowJobPayload, linkFormatter linkForm
|
||||
return text, color
|
||||
}
|
||||
|
||||
func getWorkflowStepPayloadInfo(p *api.WorkflowStepPayload, linkFormatter linkFormatter, withSender bool) (text string, color int) {
|
||||
description := p.Step.Conclusion
|
||||
if description == "" {
|
||||
description = p.Step.Status
|
||||
}
|
||||
stepLink := linkFormatter(p.WorkflowJob.HTMLURL, fmt.Sprintf("%s / %s", p.WorkflowJob.Name, p.Step.Name)+":"+description)
|
||||
|
||||
text = fmt.Sprintf("Workflow Step %s: %s", p.Action, stepLink)
|
||||
switch description {
|
||||
case "waiting":
|
||||
color = orangeColor
|
||||
case "queued":
|
||||
color = orangeColorLight
|
||||
case "success":
|
||||
color = greenColor
|
||||
case "failure":
|
||||
color = redColor
|
||||
case "cancelled":
|
||||
color = yellowColor
|
||||
case "skipped":
|
||||
color = purpleColor
|
||||
default:
|
||||
color = greyColor
|
||||
}
|
||||
if withSender {
|
||||
text += " by " + linkFormatter(setting.AppURL+url.PathEscape(p.Sender.UserName), p.Sender.UserName)
|
||||
}
|
||||
|
||||
return text, color
|
||||
}
|
||||
|
||||
// ToHook convert models.Webhook to api.Hook
|
||||
// This function is not part of the convert package to prevent an import cycle
|
||||
func ToHook(repoLink string, w *webhook_model.Webhook) (*api.Hook, error) {
|
||||
|
||||
Reference in New Issue
Block a user