-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b473275
Showing
8 changed files
with
196 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
kind: pipeline | ||
name: default | ||
|
||
steps: | ||
- name: build | ||
image: golang:1.12-alpine | ||
commands: | ||
- GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -o serverchan serverchan.go | ||
when: | ||
event: | ||
- tag | ||
|
||
- name: build-image | ||
image: plugins/docker | ||
settings: | ||
username: yakumioto | ||
password: | ||
from_secret: docker_pwd | ||
repo: yakumioto/drone-serverchan | ||
auto_tag: true | ||
when: | ||
event: | ||
- tag | ||
|
||
- name: sendmsg | ||
image: yakumioto/drone-serverchan | ||
settings: | ||
key: | ||
from_secret: serverchan_key | ||
text: succeeded | ||
desp: docker build yakumioto/serverchan | ||
when: | ||
event: | ||
- tag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Go template | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
FROM alpine:3.9 | ||
|
||
LABEL maintainer="Mioto <[email protected]>" | ||
|
||
RUN apk update && apk add --no-cache ca-certificates | ||
|
||
WORKDIR /drone/src | ||
|
||
COPY serverchan /usr/local/bin/serverchan | ||
|
||
ENTRYPOINT ["serverchan"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Yaku Mioto | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Drone ServerChan(Server酱) | ||
|
||
[](https://drone.mioto.me/yakumioto/drone-serverchan) | ||
 | ||
 | ||
|
||
drone ServerChan(Server酱) 微信消息通知插件 | ||
|
||
## 简介 | ||
|
||
基于 [ServerChan(Server酱)](http://sc.ftqq.com/3.version) 封装的微信消息通知插件 | ||
|
||
## 栗子 | ||
|
||
明文 key 配置 | ||
|
||
```yml | ||
--- | ||
kind: pipeline | ||
name: default | ||
|
||
steps: | ||
- name: send-wechat | ||
image: yakumioto/serverchan | ||
settings: | ||
key: {your key} | ||
text: {消息标题} | ||
desp: {消息内容 支持MarkDown} | ||
``` | ||
密文 key 配置 | ||
```yml | ||
--- | ||
kind: pipeline | ||
name: default | ||
|
||
steps: | ||
- name: send-wechat | ||
image: yakumioto/serverchan | ||
settings: | ||
key: | ||
from_secret: {your key} | ||
text: {消息标题} | ||
desp: {消息内容 支持MarkDown} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Plaintext key | ||
--- | ||
kind: pipeline | ||
name: default | ||
|
||
steps: | ||
- name: send-wechat | ||
image: yakumioto/serverchan | ||
settings: | ||
key: "{your key}" | ||
text: "{titel}" | ||
desp: "{content}" | ||
|
||
# Secrets Key | ||
--- | ||
kind: pipeline | ||
name: default | ||
|
||
steps: | ||
- name: send-wechat | ||
image: yakumioto/serverchan | ||
settings: | ||
key: | ||
from_secret: key | ||
text: "{titel}" | ||
desp: "{content}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module github.com/yakumioto/drone-serverchan | ||
|
||
go 1.12 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"net/http" | ||
"net/url" | ||
"os" | ||
"strings" | ||
) | ||
|
||
var ( | ||
key string | ||
text string | ||
desp string | ||
) | ||
|
||
func init() { | ||
key = os.Getenv("PLUGIN_KEY") | ||
text = os.Getenv("PLUGIN_TEXT") | ||
desp = os.Getenv("PLUGIN_DESP") | ||
} | ||
|
||
func main() { | ||
if key == "" || text == "" { | ||
log.Fatalln("key or text is required") | ||
} | ||
|
||
reqMsg := &url.Values{ | ||
"text": []string{text}, | ||
"desp": []string{desp}, | ||
} | ||
|
||
reqURL := fmt.Sprintf("https://sc.ftqq.com/%s.send", key) | ||
_, err := http.Post(reqURL, "application/x-www-form-urlencoded", strings.NewReader(reqMsg.Encode())) | ||
if err != nil { | ||
log.Fatalln("post error: ", err) | ||
} | ||
} |