mirror of
https://github.com/go-gitea/gitea.git
synced 2025-11-02 02:37:10 +01:00
Sync run status with db prior webhook delivery
* fixes status glitch of webhook * e.g. queued for cancel * e.g. completed for rerun
This commit is contained in:
parent
cdefda13a3
commit
d404c60b73
@ -459,6 +459,8 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
|
|||||||
}
|
}
|
||||||
|
|
||||||
actions_service.CreateCommitStatus(ctx, job)
|
actions_service.CreateCommitStatus(ctx, job)
|
||||||
|
// Sync run status with db
|
||||||
|
job.Run = nil
|
||||||
_ = job.LoadAttributes(ctx)
|
_ = job.LoadAttributes(ctx)
|
||||||
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
|
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
|
||||||
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
|
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 {
|
if len(updatedjobs) > 0 {
|
||||||
job := 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)
|
notify_service.WorkflowRunStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job.Run)
|
||||||
}
|
}
|
||||||
ctx.JSON(http.StatusOK, struct{}{})
|
ctx.JSON(http.StatusOK, struct{}{})
|
||||||
@ -607,14 +612,18 @@ func Approve(ctx *context_module.Context) {
|
|||||||
|
|
||||||
actions_service.CreateCommitStatus(ctx, jobs...)
|
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 {
|
for _, job := range updatedjobs {
|
||||||
_ = job.LoadAttributes(ctx)
|
_ = job.LoadAttributes(ctx)
|
||||||
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
|
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{}{})
|
ctx.JSON(http.StatusOK, struct{}{})
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,11 +127,11 @@ func CancelAbandonedJobs(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
CreateCommitStatus(ctx, job)
|
CreateCommitStatus(ctx, job)
|
||||||
if updated {
|
if updated {
|
||||||
|
// Sync run status with db
|
||||||
|
job.Run = nil
|
||||||
_ = job.LoadAttributes(ctx)
|
_ = job.LoadAttributes(ctx)
|
||||||
notify_service.WorkflowJobStatusUpdate(ctx, job.Run.Repo, job.Run.TriggerUser, job, nil)
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -80,7 +80,6 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
|
|||||||
}
|
}
|
||||||
if len(jobs) > 0 {
|
if len(jobs) > 0 {
|
||||||
runUpdated := true
|
runUpdated := true
|
||||||
run := jobs[0].Run
|
|
||||||
for _, job := range jobs {
|
for _, job := range jobs {
|
||||||
if !job.Status.IsDone() {
|
if !job.Status.IsDone() {
|
||||||
runUpdated = false
|
runUpdated = false
|
||||||
@ -88,6 +87,10 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if runUpdated {
|
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)
|
notify_service.WorkflowRunStatusUpdate(ctx, run.Repo, run.TriggerUser, run)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user