-
Notifications
You must be signed in to change notification settings - Fork 1
/
ci.go
70 lines (65 loc) · 1.54 KB
/
ci.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
68
69
70
package githubbot
import (
"fmt"
"strconv"
"github.com/cpalone/dronehook"
"github.com/cpalone/travishook"
)
func (s *Session) ciHandler() error {
// spin off travis server
tServer := travishook.NewServer(8085, "/travishook")
s.logger.Info("Starting travis server...")
tServer.GoListenAndServe()
//spin off drone server
dServer := dronehook.NewServer(8082, "/dronehook")
s.logger.Info("Starting drone server...")
dServer.GoListenAndServe()
for {
select {
case p := <-tServer.Out:
var parent string
parent, ok := s.commitParent[p.Commit]
if !ok {
parent = ""
}
var emoji string
if p.StatusMessage == "Passed" || p.StatusMessage == "Fixed" {
emoji = ":white_check_mark:"
} else {
emoji = ":no_entry:"
}
s.sendMessage(fmt.Sprintf(
"%s [ travis-ci.org | %s | Branch: %s ] (%s)",
emoji, p.Repository.Name, p.Branch, p.BuildURL),
parent, strconv.Itoa(s.msgID))
s.msgID++
case p := <-dServer.Out:
var parent string
parent, ok := s.commitParent[p.Build.Commit]
if !ok {
parent = ""
}
var emoji string
if p.Build.Status == "success" {
emoji = ":white_check_mark:"
} else {
emoji = ":no_entry:"
}
// https://drone.in.euphoria.io/euphoria-io/heim/77
url := fmt.Sprintf("drone.in.euphoria.io/%s/%s/%v",
p.Repo.Name,
p.Build.Branch,
p.Build.Number,
)
str := fmt.Sprintf("%s [ drone.io | %s | Branch: %s ] (%s)",
emoji,
p.Repo.Name,
p.Build.Branch,
url,
)
s.sendMessage(str,
parent, strconv.Itoa(s.msgID))
s.msgID++
}
}
}