From 4fe311e7c0292e3ac79f8bc063f1bcacef4494f0 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Mon, 14 Oct 2024 04:28:32 +0800 Subject: [PATCH 1/3] Update scheduled tasks even if changes are pushed by "ActionsUser" (#32246) Fix #32219 --------- Co-authored-by: delvh (cherry picked from commit 81aec6d621a3ea0dfb02d3b4d20b9be77c30c6ab) --- services/actions/notifier_helper.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/services/actions/notifier_helper.go b/services/actions/notifier_helper.go index c4bf6955ee..0a1dbb162d 100644 --- a/services/actions/notifier_helper.go +++ b/services/actions/notifier_helper.go @@ -119,11 +119,20 @@ func (input *notifyInput) Notify(ctx context.Context) { } func notify(ctx context.Context, input *notifyInput) error { + shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch if input.Doer.IsActions() { // avoiding triggering cyclically, for example: // a comment of an issue will trigger the runner to add a new comment as reply, // and the new comment will trigger the runner again. log.Debug("ignore executing %v for event %v whose doer is %v", getMethod(ctx), input.Event, input.Doer.Name) + + // we should update schedule tasks in this case, because + // 1. schedule tasks cannot be triggered by other events, so cyclic triggering will not occur + // 2. some schedule tasks may update the repo periodically, so the refs of schedule tasks need to be updated + if shouldDetectSchedules { + return DetectAndHandleSchedules(ctx, input.Repo) + } + return nil } if input.Repo.IsEmpty || input.Repo.IsArchived { @@ -182,7 +191,6 @@ func notify(ctx context.Context, input *notifyInput) error { var detectedWorkflows []*actions_module.DetectedWorkflow actionsConfig := input.Repo.MustGetUnit(ctx, unit_model.TypeActions).ActionsConfig() - shouldDetectSchedules := input.Event == webhook_module.HookEventPush && input.Ref.BranchName() == input.Repo.DefaultBranch workflows, schedules, err := actions_module.DetectWorkflows(gitRepo, commit, input.Event, input.Payload, From 1913399d8176944f170d4f1c032dc37003aaafc0 Mon Sep 17 00:00:00 2001 From: Zettat123 Date: Thu, 17 Oct 2024 17:05:38 +0800 Subject: [PATCH 2/3] Always update expiration time when creating an artifact (#32281) Fix #32256 (cherry picked from commit 9116665e9c1c01d882c919fb3058f7fdb695350e) --- models/actions/artifact.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/models/actions/artifact.go b/models/actions/artifact.go index 3d0a288e62..0bc66ba24e 100644 --- a/models/actions/artifact.go +++ b/models/actions/artifact.go @@ -69,7 +69,7 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa OwnerID: t.OwnerID, CommitSHA: t.CommitSHA, Status: int64(ArtifactStatusUploadPending), - ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + 3600*24*expiredDays), + ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays), } if _, err := db.GetEngine(ctx).Insert(artifact); err != nil { return nil, err @@ -78,6 +78,13 @@ func CreateArtifact(ctx context.Context, t *ActionTask, artifactName, artifactPa } else if err != nil { return nil, err } + + if _, err := db.GetEngine(ctx).ID(artifact.ID).Cols("expired_unix").Update(&ActionArtifact{ + ExpiredUnix: timeutil.TimeStamp(time.Now().Unix() + timeutil.Day*expiredDays), + }); err != nil { + return nil, err + } + return artifact, nil } From 893d0941a891c41c1c69554fba6082488cf8924f Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Tue, 22 Oct 2024 07:36:59 +0200 Subject: [PATCH 3/3] chore(release-notes): weekly cherry-pick week 2024-43-v9.0 --- release-notes/5647.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 release-notes/5647.md diff --git a/release-notes/5647.md b/release-notes/5647.md new file mode 100644 index 0000000000..5341a0d690 --- /dev/null +++ b/release-notes/5647.md @@ -0,0 +1,2 @@ +fix: [commit](https://codeberg.org/forgejo/forgejo/commit/1913399d8176944f170d4f1c032dc37003aaafc0) Always update expiration time when creating an artifact +fix: [commit](https://codeberg.org/forgejo/forgejo/commit/4fe311e7c0292e3ac79f8bc063f1bcacef4494f0) Update scheduled tasks even if changes are pushed by "ActionsUser"