-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
60 lines (49 loc) · 1.78 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main // (c) 2020 ken pepple ([email protected])
import (
"os"
"github.com/sethvargo/go-githubactions"
)
var (
version = "dev"
commit = "none"
date = "unknown"
)
var config map[string]string
func init() {
config = make(map[string]string)
// set Github action event variables
config["name"] = os.Getenv("GITHUB_EVENT_NAME")
config["sha"] = os.Getenv("GITHUB_SHA")
config["ref"] = os.Getenv("GITHUB_REF")
config["repo"] = os.Getenv("GITHUB_REPOSITORY")
config["path"] = os.Getenv("GITHUB_EVENT_PATH")
config["action"] = os.Getenv("GITHUB_ACTION")
config["status"] = os.Getenv("JOB_STATUS")
ga := githubactions.New()
config["pushoverRcpt"] = ga.GetInput("pushover_user") // os.Getenv("INPUT_PUSHOVER_USER")
config["pushoverToken"] = ga.GetInput("pushover_token") // os.Getenv("INPUT_PUSHOVER_TOKEN")
config["msg"] = ga.GetInput("msg") // os.Getenv("INPUT_MSG")
config["device"] = ga.GetInput("device") // os.Getenv("INPUT_DEVICE")
config["title"] = ga.GetInput("title") // os.Getenv("INPUT_TITLE")
config["priority"] = ga.GetInput("priority") // os.Getenv("INPUT_PRIORITY")
config["sound"] = ga.GetInput("sound") // os.Getenv("INPUT_SOUND")
}
func main() {
var p pushoverNotification
g := githubactions.New()
g.Warningf("%v, commit %v, built at %v\n", version, commit, date)
g.AddMask(config["pushoverRcpt"])
g.AddMask(config["pushoverToken"])
g.Debugf("Configs set: %v", config)
p, err := newPushoverNotification(config)
if err != nil {
g.Fatalf("Error with pushover credentials: %s", err)
}
g.Warningf("notification: %v", p)
// send notification to device
o, err := p.notify()
if err != nil {
g.Fatalf("notification failed: %v", err)
}
g.Debugf("notification successful: %v", o)
}