mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-02 13:00:10 +02:00
use cached task instance if available
This commit is contained in:
1 parent
20f5d6ee95
commit
a178e4be7a
3 files changed
+16
-9
No files matched your search
@@ -276,7 +276,9 @@ func ToActionsStatus(status actions_model.Status) (string, string) {
|
||||
return action, conclusion
|
||||
}
|
||||
|
||||
func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, job *actions_model.ActionRunJob) (*api.ActionWorkflowJob, error) {
|
||||
// ToActionWorkflowJob convert a actions_model.ActionRunJob to an api.ActionWorkflowJob
|
||||
// task is optional and can be nil
|
||||
func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, task *actions_model.ActionTask, job *actions_model.ActionRunJob) (*api.ActionWorkflowJob, error) {
|
||||
err := job.LoadAttributes(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -300,7 +302,12 @@ func ToActionWorkflowJob(ctx context.Context, repo *repo_model.Repository, job *
|
||||
var steps []*api.ActionWorkflowStep
|
||||
|
||||
if job.TaskID != 0 {
|
||||
task, _, _ := db.GetByID[actions_model.ActionTask](ctx, job.TaskID)
|
||||
if task == nil {
|
||||
task, _, err = db.GetByID[actions_model.ActionTask](ctx, job.TaskID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
runnerID = task.RunnerID
|
||||
if runner, ok, _ := db.GetByID[actions_model.ActionRunner](ctx, runnerID); ok {
|
||||
|
||||
@@ -956,7 +956,7 @@ func (*webhookNotifier) WorkflowJobStatusUpdate(ctx context.Context, repo *repo_
|
||||
|
||||
status, _ := convert.ToActionsStatus(job.Status)
|
||||
|
||||
convertedJob, err := convert.ToActionWorkflowJob(ctx, repo, job)
|
||||
convertedJob, err := convert.ToActionWorkflowJob(ctx, repo, task, job)
|
||||
if err != nil {
|
||||
log.Error("ToActionWorkflowJob: %v", err)
|
||||
return
|
||||
|
||||
Reference in new issue
Block a user