mirror of
https://github.com/lddsb/drone-dingtalk-message.git
synced 2026-06-14 05:13:05 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9df9c9aa37 | |||
| f931e70cc7 |
+11
-3
@@ -1,9 +1,17 @@
|
|||||||
FROM alpine:latest
|
FROM golang AS builder
|
||||||
|
WORKDIR /app
|
||||||
|
COPY . .
|
||||||
|
ENV GO111MODULE on
|
||||||
|
ENV CGO_ENABLED 0
|
||||||
|
ENV GOOS linux
|
||||||
|
RUN go build -a -o drone-dingtalk .
|
||||||
|
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
RUN apk update && \
|
RUN apk update && \
|
||||||
apk add \
|
apk add \
|
||||||
ca-certificates && \
|
ca-certificates && \
|
||||||
rm -rf /var/cache/apk/*
|
rm -rf /var/cache/apk/*
|
||||||
|
|
||||||
ADD drone-dingtalk-message /bin/
|
COPY --from=builder /app/drone-dingtalk /bin/
|
||||||
ENTRYPOINT ["/bin/drone-dingtalk-message"]
|
ENTRYPOINT ["/bin/drone-dingtalk"]
|
||||||
@@ -36,6 +36,10 @@ String. Access token for group bot. (you can get the access token when you add a
|
|||||||
|
|
||||||
String. Message type, plan support text, markdown, link and action card, but due to time issue, it's only support `markdown` and `text` now, and you can get the best experience by use markdown.
|
String. Message type, plan support text, markdown, link and action card, but due to time issue, it's only support `markdown` and `text` now, and you can get the best experience by use markdown.
|
||||||
|
|
||||||
|
`tips_title`
|
||||||
|
|
||||||
|
String. You can customize the title for the message tips, just work when message type is markdown.
|
||||||
|
|
||||||
`message_color`(when `type=markdown`)
|
`message_color`(when `type=markdown`)
|
||||||
|
|
||||||
Boolean value. This option can change the title and commit message color if turn on.
|
Boolean value. This option can change the title and commit message color if turn on.
|
||||||
|
|||||||
@@ -4,6 +4,6 @@ go 1.12
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/joho/godotenv v1.3.0
|
github.com/joho/godotenv v1.3.0
|
||||||
github.com/lddsb/dingtalk-webhook v0.0.0-20190307231412-b4abe34b5fa9
|
github.com/lddsb/dingtalk-webhook v0.0.1
|
||||||
github.com/urfave/cli v1.20.0
|
github.com/urfave/cli v1.20.0
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
|
||||||
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
|
||||||
github.com/lddsb/dingtalk-webhook v0.0.0-20190307231412-b4abe34b5fa9 h1:ZeUdCEbcT0+l10jTSyjU9+18ZbDTz6TdkH6yGiCd9dQ=
|
github.com/lddsb/dingtalk-webhook v0.0.1 h1:l4FdTMaRaHnrYfByALukFWK0ru9Rttl0dANg13/SnTI=
|
||||||
github.com/lddsb/dingtalk-webhook v0.0.0-20190307231412-b4abe34b5fa9/go.mod h1:5E+/sOBb6m+3ztqnZl4danEY3I5FeIwb12v12s9osbw=
|
github.com/lddsb/dingtalk-webhook v0.0.1/go.mod h1:5E+/sOBb6m+3ztqnZl4danEY3I5FeIwb12v12s9osbw=
|
||||||
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
|
||||||
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
|
||||||
|
|||||||
@@ -144,6 +144,11 @@ func main() {
|
|||||||
Usage: "link sha source page or not",
|
Usage: "link sha source page or not",
|
||||||
EnvVar: "PLUGIN_SHA_LINK,PLUGIN_MESSAGE_SHA_LINK",
|
EnvVar: "PLUGIN_SHA_LINK,PLUGIN_MESSAGE_SHA_LINK",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "config.tips.title",
|
||||||
|
Usage: "tips title, just work for markdown type message",
|
||||||
|
EnvVar: "PLUGIN_TIPS_TITLE",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := app.Run(os.Args); nil != err {
|
if err := app.Run(os.Args); nil != err {
|
||||||
@@ -184,10 +189,11 @@ func run(c *cli.Context) {
|
|||||||
Config: Config{
|
Config: Config{
|
||||||
AccessToken: c.String("config.token"),
|
AccessToken: c.String("config.token"),
|
||||||
//Lang: c.String("config.lang"),
|
//Lang: c.String("config.lang"),
|
||||||
IsAtALL: c.Bool("config.message.at.all"),
|
IsAtALL: c.Bool("config.message.at.all"),
|
||||||
MsgType: c.String("config.message.type"),
|
MsgType: c.String("config.message.type"),
|
||||||
Mobiles: c.String("config.message.at.mobiles"),
|
Mobiles: c.String("config.message.at.mobiles"),
|
||||||
Debug: c.Bool("config.debug"),
|
Debug: c.Bool("config.debug"),
|
||||||
|
TipsTitle: c.String("config.tips.title"),
|
||||||
},
|
},
|
||||||
Extra: Extra{
|
Extra: Extra{
|
||||||
Pic: ExtraPic{
|
Pic: ExtraPic{
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ type (
|
|||||||
Mobiles string
|
Mobiles string
|
||||||
Username string
|
Username string
|
||||||
MsgType string
|
MsgType string
|
||||||
|
TipsTitle string
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageConfig `DingTalk message struct`
|
// MessageConfig `DingTalk message struct`
|
||||||
@@ -108,11 +109,15 @@ func (p *Plugin) Exec() error {
|
|||||||
return errors.New("commit sha cannot short than 6")
|
return errors.New("commit sha cannot short than 6")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if p.Config.TipsTitle == "" {
|
||||||
|
p.Config.TipsTitle = "you have a new message"
|
||||||
|
}
|
||||||
|
|
||||||
newWebhook := webhook.NewWebHook(p.Config.AccessToken)
|
newWebhook := webhook.NewWebHook(p.Config.AccessToken)
|
||||||
mobiles := strings.Split(p.Config.Mobiles, ",")
|
mobiles := strings.Split(p.Config.Mobiles, ",")
|
||||||
switch strings.ToLower(p.Config.MsgType) {
|
switch strings.ToLower(p.Config.MsgType) {
|
||||||
case "markdown":
|
case "markdown":
|
||||||
err = newWebhook.SendMarkdownMsg("You have a new message...", p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
err = newWebhook.SendMarkdownMsg(p.Config.TipsTitle, p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
||||||
case "text":
|
case "text":
|
||||||
err = newWebhook.SendTextMsg(p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
err = newWebhook.SendTextMsg(p.baseTpl(), p.Config.IsAtALL, mobiles...)
|
||||||
case "link":
|
case "link":
|
||||||
|
|||||||
Reference in New Issue
Block a user