feat(GitHub): support default message

This commit is contained in:
Bo-Yi Wu
2019-02-17 16:03:10 +08:00
parent 4d2a304048
commit 71a0551697
3 changed files with 70 additions and 21 deletions
+19
View File
@@ -13,6 +13,15 @@ import (
)
type (
// GitHub information.
GitHub struct {
Workflow string
Workspace string
Action string
EventName string
EventPath string
}
// Repo information.
Repo struct {
FullName string
@@ -65,6 +74,7 @@ type (
// Plugin values.
Plugin struct {
GitHub GitHub
Repo Repo
Commit Commit
Build Build
@@ -370,6 +380,15 @@ func (p Plugin) Send(bot *tgbotapi.BotAPI, msg tgbotapi.Chattable) error {
// Message is plugin default message.
func (p Plugin) Message() []string {
if p.Config.GitHub {
return []string{fmt.Sprintf("%s/%s triggered by %s (%s)",
p.Repo.FullName,
p.GitHub.Workflow,
p.Repo.Namespace,
p.GitHub.EventName,
)}
}
return []string{fmt.Sprintf("[%s] <%s> (%s)『%s』by %s",
p.Build.Status,
p.Build.Link,