diff options
author | yp05327 <576951401@qq.com> | 2024-04-20 09:35:29 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-20 02:35:29 +0200 |
commit | cb6814adad4dc81a683b50826a211ce7bce731d7 (patch) | |
tree | 34b4b921a852c6f5326777ff62c5a403dec6cab4 /services/actions | |
parent | 53cf46cae7475befa2dde554bbd9147e436072b9 (diff) | |
download | gitea-cb6814adad4dc81a683b50826a211ce7bce731d7.tar.gz gitea-cb6814adad4dc81a683b50826a211ce7bce731d7.zip |
Use action user as the trigger user of schedules (#30581)
Follow https://github.com/go-gitea/gitea/pull/30357
When user push to default branch, the schedule trigger user will be the
user.
When disable then enable action units in settings, the schedule trigger
user will be action user.
When repo is a mirror, the schedule trigger user will be action user. (
before it will return error, fixed by #30357)
As scheduled job is a cron, the trigger user should be action user from
Gitea, not a real user.
---------
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'services/actions')
-rw-r--r-- | services/actions/notifier_helper.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index c48886a824..6fb6421887 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 @@ -485,7 +490,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, @@ -527,7 +532,7 @@ func DetectAndHandleSchedules(ctx context.Context, repo *repo_model.Repository) // 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) + notifyInput := newNotifyInputForSchedules(repo) return handleSchedules(ctx, scheduleWorkflows, commit, notifyInput, repo.DefaultBranch) } |