diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index b04d81a274..30d16b8dc9 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -459,6 +459,8 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou } actions_service.CreateCommitStatus(ctx, job) + // Sync run status with db + job.Run = nil _ = job.LoadAttributes(ctx) notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil) @@ -564,6 +566,9 @@ func Cancel(ctx *context_module.Context) { } if len(updatedjobs) > 0 { job := updatedjobs[0] + // Sync run status with db + job.Run = nil + job.LoadAttributes(ctx) notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) } ctx.JSON(http.StatusOK, struct{}{}) @@ -607,14 +612,18 @@ func Approve(ctx *context_module.Context) { actions_service.CreateCommitStatus(ctx, jobs...) + if len(updatedjobs) > 0 { + job := updatedjobs[0] + // Sync run status with db + job.Run = nil + job.LoadAttributes(ctx) + notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) + } + for _, job := range updatedjobs { _ = job.LoadAttributes(ctx) notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil) } - if len(updatedjobs) > 0 { - job := updatedjobs[0] - notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) - } ctx.JSON(http.StatusOK, struct{}{}) } diff --git a/services/actions/clear_tasks.go b/services/actions/clear_tasks.go index e68719c4f8..d74e3f43e2 100644 --- a/services/actions/clear_tasks.go +++ b/services/actions/clear_tasks.go @@ -127,11 +127,11 @@ func CancelAbandonedJobs(ctx context.Context) error { } CreateCommitStatus(ctx, job) if updated { + // Sync run status with db + job.Run = nil _ = job.LoadAttributes(ctx) notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil) - if job.Run != nil { - notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) - } + notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run) } } diff --git a/services/actions/job_emitter.go b/services/actions/job_emitter.go index c77771d6be..6504c8e1bb 100644 --- a/services/actions/job_emitter.go +++ b/services/actions/job_emitter.go @@ -80,7 +80,6 @@ func checkJobsOfRun(ctx context.Context, runID int64) error { } if len(jobs) > 0 { runUpdated := true - run := jobs[0].Run for _, job := range jobs { if !job.Status.IsDone() { runUpdated = false @@ -88,6 +87,10 @@ func checkJobsOfRun(ctx context.Context, runID int64) error { } } if runUpdated { + // Sync run status with db + jobs[0].Run = nil + jobs[0].LoadAttributes(ctx) + run := jobs[0].Run notify_service.WorkflowRunStatusUpdate(ctx, run.Repo, run.TriggerUser, run) } }