-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.go
49 lines (41 loc) · 1011 Bytes
/
release.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
package gittt
import (
"encoding/json"
"log"
)
type Release struct {
Action string `json:"action"`
ReleaseInfo ReleaseInfo `json:"release"`
}
type ReleaseInfo struct {
Name string `json:"name"`
Draft bool `json:"draft"`
Tag string `json:"tag_name"`
BranchTarget string `json:"target_commitish"`
}
func ReleaseTrigger(g *Gittt, data []byte) error {
var r Release
err := json.Unmarshal(data, &r)
if err != nil {
return err
}
log.Println("Release Event Received")
actions := g.matchConditionals(ReleaseEvent, r)
for _, action := range actions {
action.Do(r)
}
return nil
}
func (g *Gittt) ConditionReleaseFromOneOf(data interface{}, branches ...interface{}) bool {
if r, ok := data.(Release); ok {
if !r.ReleaseInfo.Draft {
for _, branch := range branches {
if r.ReleaseInfo.BranchTarget == branch.(string) {
log.Printf("Condition match: Release created from %s\n", branch.(string))
return true
}
}
}
}
return false
}