From 73c4f5ee28cdb7653054f674250ee6221a8f36c9 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 19 Apr 2024 01:41:24 +0000 Subject: [PATCH 1/3] improve --- services/actions/notifier_helper.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index c48886a8246eb..da47075ec607d 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -78,6 +78,10 @@ func newNotifyInput(repo *repo_model.Repository, doer *user_model.User, event we } } +func newNotifyInputForSchedules(repo *repo_model.Repository) *notifyInput { + return newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) +} + func (input *notifyInput) WithDoer(doer *user_model.User) *notifyInput { input.Doer = doer return input @@ -485,7 +489,7 @@ func handleSchedules( RepoID: input.Repo.ID, OwnerID: input.Repo.OwnerID, WorkflowID: dwf.EntryName, - TriggerUserID: input.Doer.ID, + TriggerUserID: user_model.ActionsUserID, Ref: ref, CommitSHA: commit.ID.String(), Event: input.Event, @@ -524,10 +528,5 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) return nil } - // We need a notifyInput to call handleSchedules - // if repo is a mirror, commit author maybe an external user, - // so we use action user as the Doer of the notifyInput - notifyInput := newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) - - return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) + return handleSchedules(ctx, scheduleWorkflows, commit, newNotifyInputForSchedules(repo), repo.DefaultBranch) } From a9875e744238f9e01795638bca7283f780c92007 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 19 Apr 2024 04:10:54 +0000 Subject: [PATCH 2/3] revert some changes --- services/actions/notifier_helper.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index da47075ec607d..bbebd0a1ea182 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -78,10 +78,6 @@ func newNotifyInput(repo *repo_model.Repository, doer *user_model.User, event we } } -func newNotifyInputForSchedules(repo *repo_model.Repository) *notifyInput { - return newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) -} - func (input *notifyInput) WithDoer(doer *user_model.User) *notifyInput { input.Doer = doer return input @@ -528,5 +524,8 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) return nil } - return handleSchedules(ctx, scheduleWorkflows, commit, newNotifyInputForSchedules(repo), repo.DefaultBranch) + // We need a notifyInput to call handleSchedules + notifyInput := newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) + + return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) } From dc01fcae62815b54fc7890b93f13149ad65cd307 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 19 Apr 2024 07:40:46 +0000 Subject: [PATCH 3/3] revert revert some changes --- services/actions/notifier_helper.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index bbebd0a1ea182..6fb6421887e4d 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -78,6 +78,11 @@ func newNotifyInput(repo *repo_model.Repository, doer *user_model.User, event we } } +func newNotifyInputForSchedules(repo *repo_model.Repository) *notifyInput { + // the doer here will be ignored as we force using action user when handling schedules + return newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) +} + func (input *notifyInput) WithDoer(doer *user_model.User) *notifyInput { input.Doer = doer return input @@ -525,7 +530,9 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) } // We need a notifyInput to call handleSchedules - notifyInput := newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) + // if repo is a mirror, commit author maybe an external user, + // so we use action user as the Doer of the notifyInput + notifyInput := newNotifyInputForSchedules(repo) return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) }