-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
49 lines (38 loc) · 1.15 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
package main
import (
"os"
"github.com/Rindrics/require-label-prefix-single/application"
"github.com/Rindrics/require-label-prefix-single/domain"
"github.com/Rindrics/require-label-prefix-single/infra"
)
func main() {
logger := infra.ParseLogLevel()
logger.Info("Loading webhook event")
event, err := infra.LoadEventFromEnv()
if err != nil {
logger.Error("Failed to load event from environment", "error", err)
return
}
logger.Info("Parsing webhook event")
eventInfo := infra.ParseEvent(event, logger)
config := application.NewConfig()
logger.Debug("config", "loaded", config)
logger.Debug("event info", "number", eventInfo.Number, "labels", eventInfo.Labels)
rl := domain.RequiredLabel{
Prefix: config.Prefix,
Separator: config.Separator,
}
found := rl.DoExist(eventInfo.Labels)
if found {
logger.Info("found label with required prefix")
os.Exit(0)
}
logger.Info("label with required prefix not found")
client := infra.NewGitHubClient(config.Token, logger)
app := application.New(eventInfo, client, *config, logger)
err = app.Run()
if err != nil {
logger.Error("Error running application", "error", err)
os.Exit(1)
}
}