-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
44 lines (36 loc) · 1.03 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
package main
import (
"log/slog"
"net/http"
"os"
"github.com/bradleyfalzon/ghinstallation"
"github.com/gin-gonic/gin"
"github.com/google/go-github/v68/github"
"github.com/patrickblackjr/prow-lite/plugins"
"github.com/rs/zerolog/log"
sloggin "github.com/samber/slog-gin"
)
func initGithubApp() *github.Client {
itr, err := ghinstallation.NewKeyFromFile(http.DefaultTransport, 269804, 32477892, "prow-lite-qa.2025-01-13.private-key.pem")
if err != nil {
log.Error().Err(err).Msg("failed to create github app client")
}
client := github.NewClient(&http.Client{Transport: itr})
return client
}
func main() {
logger := slog.New(slog.NewTextHandler(os.Stdout, nil))
r := gin.New()
r.SetTrustedProxies(nil)
r.Use(sloggin.New(logger))
r.Use(gin.Recovery())
r.GET("/", func(ctx *gin.Context) {
ctx.JSON(http.StatusOK, gin.H{
"message": "ok",
})
})
client := initGithubApp()
registerEventHandlers(r, client, logger, plugins.ProcessComment)
logger.Info("server is running", slog.String("port", "8080"))
r.Run(":8080")
}