@@ -101,6 +101,12 @@ func (d DiggerController) GithubAppWebHook(c *gin.Context) {
101101				return 
102102			}
103103		}
104+ 	case  * github.PushEvent :
105+ 		slog .Info ("Processing PushEvent" ,
106+ 			"repo" , * event .Repo .FullName ,
107+ 		)
108+ 
109+ 		go  handlePushEvent (gh , event , appId64 )
104110
105111	case  * github.IssueCommentEvent :
106112		slog .Info ("Processing IssueCommentEvent" ,
@@ -384,11 +390,40 @@ func handleInstallationDeletedEvent(installation *github.InstallationEvent, appI
384390	return  nil 
385391}
386392
393+ func  handlePushEvent (gh  utils.GithubClientProvider , payload  * github.PushEvent , appId  int64 ) error  {
394+ 	slog .Debug ("Handling push event" , "appId" , appId , "payload" , payload )
395+ 	defer  func () {
396+ 		if  r  :=  recover (); r  !=  nil  {
397+ 			stack  :=  string (debug .Stack ())
398+ 			slog .Error ("Recovered from panic in handlePushEvent" , "error" , r )
399+ 			fmt .Printf ("Stack trace:\n %s\n " , stack )
400+ 		}
401+ 	}()
402+ 
403+ 	installationId  :=  * payload .Installation .ID 
404+ 	repoName  :=  * payload .Repo .Name 
405+ 	repoOwner  :=  * payload .Repo .Owner .Login 
406+ 	repoFullName  :=  * payload .Repo .FullName 
407+ 	cloneURL  :=  * payload .Repo .CloneURL 
408+ 	ref  :=  * payload .Ref 
409+ 	defaultBranch  :=  * payload .Repo .DefaultBranch 
410+ 
411+ 	if  strings .HasSuffix (ref , defaultBranch ) {
412+ 		err  :=  services .LoadProjectsFromGithubRepo (gh , strconv .FormatInt (installationId , 10 ), repoFullName , repoOwner , repoName , cloneURL , defaultBranch )
413+ 		if  err  !=  nil  {
414+ 			slog .Error ("Failed to load projects from GitHub repo" , "error" , err )
415+ 		}
416+ 	}
417+ 
418+ 	return  nil 
419+ }
420+ 
387421func  handlePullRequestEvent (gh  utils.GithubClientProvider , payload  * github.PullRequestEvent , ciBackendProvider  ci_backends.CiBackendProvider , appId  int64 ) error  {
388422	defer  func () {
389423		if  r  :=  recover (); r  !=  nil  {
390424			stack  :=  string (debug .Stack ())
391- 			slog .Error ("Recovered from panic in handlePullRequestEvent" , "error" , r , slog .Group ("stack" , slog .String ("trace" , stack )))
425+ 			slog .Error ("Recovered from panic in handlePullRequestEvent" , "error" , r , slog .Group ("stack" ))
426+ 			fmt .Printf ("Stack trace:\n %s\n " , stack )
392427		}
393428	}()
394429
@@ -1151,7 +1186,8 @@ func handleIssueCommentEvent(gh utils.GithubClientProvider, payload *github.Issu
11511186	defer  func () {
11521187		if  r  :=  recover (); r  !=  nil  {
11531188			stack  :=  string (debug .Stack ())
1154- 			slog .Error ("Recovered from panic in handleIssueCommentEvent" , "error" , r , slog .Group ("stack" , slog .String ("trace" , stack )))
1189+ 			slog .Error ("Recovered from panic in handleIssueCommentEvent" , "error" , r , slog .Group ("stack" ))
1190+ 			fmt .Printf ("Stack trace:\n %s\n " , stack )
11551191		}
11561192	}()
11571193
0 commit comments