From 39408ede5e38989282f2212624ca23b1611729f9 Mon Sep 17 00:00:00 2001 From: Masayoshi Mizutani Date: Mon, 10 Jun 2024 15:22:17 +0900 Subject: [PATCH] Ignore push event if no head commit ID (#107) --- pkg/controller/server/github.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/controller/server/github.go b/pkg/controller/server/github.go index e3b2345..65e8f3c 100644 --- a/pkg/controller/server/github.go +++ b/pkg/controller/server/github.go @@ -52,6 +52,11 @@ func refToBranch(v string) string { func githubEventToScanInput(event interface{}) *model.ScanGitHubRepoInput { switch ev := event.(type) { case *github.PushEvent: + if ev.HeadCommit == nil || ev.HeadCommit.ID == nil { + utils.Logger().Warn("ignore push event without head commit", slog.Any("event", ev)) + return nil + } + return &model.ScanGitHubRepoInput{ GitHubMetadata: model.GitHubMetadata{ GitHubCommit: model.GitHubCommit{