-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpushover-actions.go
67 lines (54 loc) · 1.42 KB
/
pushover-actions.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
61
62
63
64
65
66
67
// Copyright 2020 Clivern. All rights reserved.
// Use of this source code is governed by the MIT
// license that can be found in the LICENSE file.
package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"github.com/clivern/pushover-actions/internal/app/handler"
"github.com/clivern/pushover-actions/internal/app/module"
log "github.com/sirupsen/logrus"
)
func init() {
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stdout)
log.SetLevel(log.InfoLevel)
}
func main() {
configFile := "/github/workflow/event.json"
eventsData, err := ioutil.ReadFile(configFile)
if err != nil {
panic(fmt.Sprintf(
"Error while reading event file [%s]: %s\n",
configFile,
err.Error(),
))
}
watchTower := module.WatchTower{}
watchTower.Add(handler.NewIssue{})
watchTower.Add(handler.EditIssue{})
watchTower.Notify(string(eventsData))
httpClient := module.NewHTTPClient()
response, error := httpClient.Post(
context.Background(),
"https://api.pushover.net/1/messages.json",
fmt.Sprintf(
"token=%s&user=%s&title=%s&sound=none&message=%s",
os.Getenv("PUSHOVER_TOKEN"),
os.Getenv("PUSHOVER_USER"),
"Hooray!",
fmt.Sprintf("Something Just Happened. Github Token %s", os.Getenv("GITHUB_TOKEN")),
),
map[string]string{},
map[string]string{},
)
if error != nil {
panic(fmt.Sprintf(
"Error while calling pushover: %s\n",
error.Error(),
))
}
fmt.Printf(httpClient.ToString(response))
}