diff options
author | yp05327 <576951401@qq.com> | 2024-04-11 16:11:32 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-11 15:11:32 +0800 |
commit | 96d31fe0a8b88c09488989cd5459d4124dcb7983 (patch) | |
tree | 9ac2ec35016d3540b318869bf632fda3e83c65a6 /services/actions | |
parent | f3cc00626b5a170e193961b885d4e60088ef7d9b (diff) | |
download | gitea-96d31fe0a8b88c09488989cd5459d4124dcb7983.tar.gz gitea-96d31fe0a8b88c09488989cd5459d4124dcb7983.zip |
Avoid user does not exist error when detecting schedule actions when the commit author is an external user (#30357)

When repo is a mirror, and commit author is an external user, then
`GetUserByEmail` will return error.
reproduce/test:
- mirror Gitea to your instance
- disable action and enable it again, this will trigger
`DetectAndHandleSchedules`
ps: also follow #24706, it only fixed normal runs, not scheduled runs.
Diffstat (limited to 'services/actions')
-rw-r--r-- | services/actions/notifier_helper.go | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index 8c98f56af5..c48886a824 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -525,12 +525,9 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) } // We need a notifyInput to call handleSchedules - // Here we use the commit author as the Doer of the notifyInput - commitUser, err := user_model.GetUserByEmail(ctx, commit.Author.Email) - if err != nil { - return fmt.Errorf("get user by email: %w", err) - } - notifyInput := newNotifyInput(repo, commitUser, 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 := newNotifyInput(repo, user_model.NewActionsUser(), webhook_module.HookEventSchedule) return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) } |