From f9bf040a5a42df5629115ca9d61b808105fd67a1 Mon Sep 17 00:00:00 2001
From: Giteabot <teabot@gitea.io>
Date: Sun, 14 May 2023 04:55:58 -0400
Subject: [PATCH] Fix run list broken when trigger user deleted (#24706)
 (#24709)

Backport #24706 by @lunny

Fix #24682

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
(cherry picked from commit 2fea93b2d38149db50c4ac999f952bacf10b5b0b)
---
 models/actions/run_list.go | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/models/actions/run_list.go b/models/actions/run_list.go
index f9d8417227..109d4446d8 100644
--- a/models/actions/run_list.go
+++ b/models/actions/run_list.go
@@ -45,6 +45,9 @@ func (runs RunList) LoadTriggerUser(ctx context.Context) error {
 			run.TriggerUser = user_model.NewActionsUser()
 		} else {
 			run.TriggerUser = users[run.TriggerUserID]
+			if run.TriggerUser == nil {
+				run.TriggerUser = user_model.NewGhostUser()
+			}
 		}
 	}
 	return nil