From 6721e4001734c973fa71e4961ae99a2f4cc452d2 Mon Sep 17 00:00:00 2001 From: fredix Date: Sun, 9 Jun 2019 14:49:22 +0200 Subject: [PATCH] first commit --- .gitignore | 1 + README.md | 7 +++++++ drone-gotify.go | 27 +++++++++++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 .gitignore create mode 100644 drone-gotify.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a97021c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +drone-gotify diff --git a/README.md b/README.md index 77bdb4b..7919b8f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,9 @@ # drone-gotify +environment variables : + +PLUGIN_ENDPOINT=https://gotify.server +PLUGIN_TOKEN=APPLICATION_TOKEN +PLUGIN_TITLE="from drone-gotify" +PLUGIN_MESSAGE="test" +PLUGIN_PRIORITY=5 diff --git a/drone-gotify.go b/drone-gotify.go new file mode 100644 index 0000000..e4ffe70 --- /dev/null +++ b/drone-gotify.go @@ -0,0 +1,27 @@ +package main + +import ( + "net/http" + "net/url" + "os" + "log" +) + +// https://gotify.net/docs/more-pushmsg#golang +// https://docs.drone.io/plugins/examples/golang/ + +func main() { + token := os.Getenv("PLUGIN_TOKEN") + endpoint := os.Getenv("PLUGIN_ENDPOINT") + title := os.Getenv("PLUGIN_TITLE") + message := os.Getenv("PLUGIN_MESSAGE") + priority := os.Getenv("PLUGIN_PRIORITY") + + resp, err := http.PostForm(endpoint + "/message?token=" + token, url.Values{"message": {message}, "title": {title}, "priority": {priority}}) + if resp != nil { + resp.Body.Close() + } + if err != nil { + log.Fatalln(err) + } +}