Skip to content

Commit 618f044

Browse files
committed
Rename notifier to WorkflowJobStatusUpdate
* add URL field * add HTMLURL field * fix run_url to return api url instead of html url
1 parent ab8bab9 commit 618f044

File tree

13 files changed

+39
-19
lines changed

13 files changed

+39
-19
lines changed

modules/structs/repo_actions.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ type ActionWorkflowStep struct {
112112
// ActionWorkflowJob represents a WorkflowJob
113113
type ActionWorkflowJob struct {
114114
ID int64 `json:"id"`
115+
URL string `json:"url"`
116+
HtmlURL string `json:"html_url"`
115117
RunID int64 `json:"run_id"`
116118
RunURL string `json:"run_url"`
117119
Name string `json:"name"`

routers/api/actions/runner/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ func (s *Service) UpdateTask(
221221
}
222222

223223
if task.Status.IsDone() {
224-
notifier.CreateWorkflowJob(ctx, task.Job.Run.Repo, task.Job.Run.TriggerUser, task.Job, task)
224+
notifier.WorkflowJobStatusUpdate(ctx, task.Job.Run.Repo, task.Job.Run.TriggerUser, task.Job, task)
225225
}
226226

227227
if req.Msg.State.Result != runnerv1.Result_RESULT_UNSPECIFIED {

routers/web/repo/actions/view.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
460460

461461
actions_service.CreateCommitStatus(ctx, job)
462462
_ = job.LoadAttributes(ctx)
463-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
463+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
464464

465465
return nil
466466
}
@@ -559,7 +559,7 @@ func Cancel(ctx *context_module.Context) {
559559

560560
for _, job := range updatedjobs {
561561
_ = job.LoadAttributes(ctx)
562-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
562+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
563563
}
564564

565565
ctx.JSON(http.StatusOK, struct{}{})
@@ -605,7 +605,7 @@ func Approve(ctx *context_module.Context) {
605605

606606
for _, job := range updatedjobs {
607607
_ = job.LoadAttributes(ctx)
608-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
608+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
609609
}
610610

611611
ctx.JSON(http.StatusOK, struct{}{})

services/actions/clear_tasks.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func stopTasks(ctx context.Context, opts actions_model.FindTaskOptions) error {
7171
CreateCommitStatus(ctx, jobs...)
7272
for _, job := range jobs {
7373
_ = job.LoadAttributes(ctx)
74-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
74+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
7575
}
7676
return nil
7777
}
@@ -103,7 +103,7 @@ func CancelAbandonedJobs(ctx context.Context) error {
103103
CreateCommitStatus(ctx, job)
104104
if updated {
105105
_ = job.LoadAttributes(ctx)
106-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
106+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
107107
}
108108
}
109109

services/actions/job_emitter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
7676
CreateCommitStatus(ctx, jobs...)
7777
for _, job := range updatedjobs {
7878
_ = job.LoadAttributes(ctx)
79-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
79+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
8080
}
8181
return nil
8282
}

services/actions/notifier_helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func handleWorkflows(
365365
}
366366
CreateCommitStatus(ctx, alljobs...)
367367
for _, job := range alljobs {
368-
notifier.CreateWorkflowJob(ctx, input.Repo, input.Doer, job, nil)
368+
notifier.WorkflowJobStatusUpdate(ctx, input.Repo, input.Doer, job, nil)
369369
}
370370
}
371371
return nil

services/actions/schedule_tasks.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func CreateScheduleTask(ctx context.Context, cron *actions_model.ActionSchedule)
158158
log.Error("LoadAttributes: %v", err)
159159
}
160160
for _, job := range allJobs {
161-
notifier.CreateWorkflowJob(ctx, run.Repo, run.TriggerUser, job, nil)
161+
notifier.WorkflowJobStatusUpdate(ctx, run.Repo, run.TriggerUser, job, nil)
162162
}
163163

164164
// Return nil if no errors occurred

services/actions/task.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func PickTask(ctx context.Context, runner *actions_model.ActionRunner) (*runnerv
7777
}
7878

7979
CreateCommitStatus(ctx, job)
80-
notifier.CreateWorkflowJob(ctx, job.Run.Repo, job.Run.TriggerUser, job, actionTask)
80+
notifier.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, actionTask)
8181

8282
return task, true, nil
8383
}

services/actions/workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
278278
}
279279
CreateCommitStatus(ctx, allJobs...)
280280
for _, job := range allJobs {
281-
notifier.CreateWorkflowJob(ctx, repo, doer, job, nil)
281+
notifier.WorkflowJobStatusUpdate(ctx, repo, doer, job, nil)
282282
}
283283

284284
return nil

services/notify/notifier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,5 @@ type Notifier interface {
7979

8080
CreateCommitStatus(ctx context.Context, repo *repo_model.Repository, commit *repository.PushCommit, sender *user_model.User, status *git_model.CommitStatus)
8181

82-
CreateWorkflowJob(ctx context.Context, repo *repo_model.Repository, sender *user_model.User, job *actions_model.ActionRunJob, task *actions_model.ActionTask)
82+
WorkflowJobStatusUpdate(ctx context.Context, repo *repo_model.Repository, sender *user_model.User, job *actions_model.ActionRunJob, task *actions_model.ActionTask)
8383
}

0 commit comments

Comments
 (0)