-
Notifications
You must be signed in to change notification settings - Fork 15
/
main_push.go
42 lines (35 loc) · 980 Bytes
/
main_push.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
package main
import (
"github.com/gin-gonic/gin"
"github.com/google/go-github/v28/github"
clientgithub "github.com/mendersoftware/integration-test-runner/client/github"
)
func processGitHubPush(
ctx *gin.Context,
push *github.PushEvent,
githubClient clientgithub.Client,
conf *config,
) error {
log := getCustomLoggerFromContext(ctx)
repoName := push.GetRepo().GetName()
repoOrg := push.GetRepo().GetOrganization()
refName := push.GetRef()
log.Debugf("Got push event :: repo %s :: ref %s", repoName, refName)
if len(conf.reposSyncList) == 0 || isRepoManaged(repoName, conf.reposSyncList) {
log.Debugf("Syncing repo %s/%s", repoOrg, repoName)
err := syncRemoteRef(log, repoOrg, repoName, refName, conf)
if err != nil {
log.Errorf("Could not sync branch: %s", err.Error())
return err
}
}
return nil
}
func isRepoManaged(repo string, reposList []string) bool {
for _, r := range reposList {
if r == repo {
return true
}
}
return false
}