diff --git a/services/notify/notifier.go b/services/notify/notifier.go index 00f98942d9..4d88a7ab95 100644 --- a/services/notify/notifier.go +++ b/services/notify/notifier.go @@ -6,6 +6,7 @@ package notify import ( "context" + actions_model "forgejo.org/models/actions" issues_model "forgejo.org/models/issues" packages_model "forgejo.org/models/packages" repo_model "forgejo.org/models/repo" @@ -76,4 +77,6 @@ type Notifier interface { PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) + + ActionRunNowDone(ctx context.Context, run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) } diff --git a/services/notify/notify.go b/services/notify/notify.go index fb30dfb609..9c50f69059 100644 --- a/services/notify/notify.go +++ b/services/notify/notify.go @@ -6,6 +6,7 @@ package notify import ( "context" + actions_model "forgejo.org/models/actions" issues_model "forgejo.org/models/issues" packages_model "forgejo.org/models/packages" repo_model "forgejo.org/models/repo" @@ -374,3 +375,13 @@ func ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) { notifier.ChangeDefaultBranch(ctx, repo) } } + +// ActionRunNowDone notifies that the old status priorStatus with (priorStatus.isDone() == false) of an ActionRun changed to run.Status with (run.Status.isDone() == true) +// lastRun might be nil (e.g. when the run is the first for this workflow). It is the last run of the same workflow for the same repo. +// It can be used to figure out if a successful run follows a failed one. +// Both run and lastRun need their attributes loaded. +func ActionRunNowDone(ctx context.Context, run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) { + for _, notifier := range notifiers { + notifier.ActionRunNowDone(ctx, run, priorStatus, lastRun) + } +} diff --git a/services/notify/null.go b/services/notify/null.go index 7182e69abb..9c76e5cbd3 100644 --- a/services/notify/null.go +++ b/services/notify/null.go @@ -6,6 +6,7 @@ package notify import ( "context" + actions_model "forgejo.org/models/actions" issues_model "forgejo.org/models/issues" packages_model "forgejo.org/models/packages" repo_model "forgejo.org/models/repo" @@ -211,3 +212,7 @@ func (*NullNotifier) PackageDelete(ctx context.Context, doer *user_model.User, p // ChangeDefaultBranch places a place holder function func (*NullNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) { } + +// ActionRunNowDone places a place holder function +func (*NullNotifier) ActionRunNowDone(ctx context.Context, run *actions_model.ActionRun, priorStatus actions_model.Status, lastRun *actions_model.ActionRun) { +}