mirror of
https://github.com/go-gitea/gitea.git
synced 2024-12-04 14:46:57 -05:00
Add a new event for actions finished and send email to related users
This commit is contained in:
parent
663acd0b46
commit
c07ed745c7
@ -12,7 +12,9 @@ import (
|
|||||||
actions_model "code.gitea.io/gitea/models/actions"
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
"code.gitea.io/gitea/models/db"
|
"code.gitea.io/gitea/models/db"
|
||||||
"code.gitea.io/gitea/modules/graceful"
|
"code.gitea.io/gitea/modules/graceful"
|
||||||
|
"code.gitea.io/gitea/modules/log"
|
||||||
"code.gitea.io/gitea/modules/queue"
|
"code.gitea.io/gitea/modules/queue"
|
||||||
|
notify_service "code.gitea.io/gitea/services/notify"
|
||||||
|
|
||||||
"github.com/nektos/act/pkg/jobparser"
|
"github.com/nektos/act/pkg/jobparser"
|
||||||
"xorm.io/builder"
|
"xorm.io/builder"
|
||||||
@ -71,6 +73,14 @@ func checkJobsOfRun(ctx context.Context, runID int64) error {
|
|||||||
}); err != nil {
|
}); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run, _, err := db.GetByID[actions_model.ActionRun](ctx, runID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("GetByID failed: %v", err)
|
||||||
|
} else if run.Status == actions_model.StatusSuccess || run.Status == actions_model.StatusFailure {
|
||||||
|
notify_service.ActionRunFinished(ctx, run)
|
||||||
|
}
|
||||||
|
|
||||||
CreateCommitStatus(ctx, jobs...)
|
CreateCommitStatus(ctx, jobs...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
activities_model "code.gitea.io/gitea/models/activities"
|
activities_model "code.gitea.io/gitea/models/activities"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@ -202,3 +203,7 @@ func (m *mailNotifier) RepoPendingTransfer(ctx context.Context, doer, newOwner *
|
|||||||
log.Error("SendRepoTransferNotifyMail: %v", err)
|
log.Error("SendRepoTransferNotifyMail: %v", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *mailNotifier) ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {
|
||||||
|
// TODO: send email to related users
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@ package notify
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
packages_model "code.gitea.io/gitea/models/packages"
|
packages_model "code.gitea.io/gitea/models/packages"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@ -74,4 +75,6 @@ type Notifier interface {
|
|||||||
PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor)
|
PackageDelete(ctx context.Context, doer *user_model.User, pd *packages_model.PackageDescriptor)
|
||||||
|
|
||||||
ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository)
|
ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository)
|
||||||
|
|
||||||
|
ActionRunFinished(ctx context.Context, run *actions_model.ActionRun)
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ package notify
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
packages_model "code.gitea.io/gitea/models/packages"
|
packages_model "code.gitea.io/gitea/models/packages"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@ -367,3 +368,10 @@ func ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
|||||||
notifier.ChangeDefaultBranch(ctx, repo)
|
notifier.ChangeDefaultBranch(ctx, repo)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionRunFinished represents action run finished
|
||||||
|
func ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {
|
||||||
|
for _, notifier := range notifiers {
|
||||||
|
notifier.ActionRunFinished(ctx, run)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -6,6 +6,7 @@ package notify
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
actions_model "code.gitea.io/gitea/models/actions"
|
||||||
issues_model "code.gitea.io/gitea/models/issues"
|
issues_model "code.gitea.io/gitea/models/issues"
|
||||||
packages_model "code.gitea.io/gitea/models/packages"
|
packages_model "code.gitea.io/gitea/models/packages"
|
||||||
repo_model "code.gitea.io/gitea/models/repo"
|
repo_model "code.gitea.io/gitea/models/repo"
|
||||||
@ -208,3 +209,6 @@ func (*NullNotifier) PackageDelete(ctx context.Context, doer *user_model.User, p
|
|||||||
// ChangeDefaultBranch places a place holder function
|
// ChangeDefaultBranch places a place holder function
|
||||||
func (*NullNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
func (*NullNotifier) ChangeDefaultBranch(ctx context.Context, repo *repo_model.Repository) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ActionRunFinished represents action run finished
|
||||||
|
func (*NullNotifier) ActionRunFinished(ctx context.Context, run *actions_model.ActionRun) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user