@@ -106,6 +106,12 @@ func (d DiggerController) GithubAppWebHook(c *gin.Context) {
106
106
}
107
107
case * github.PushEvent :
108
108
log .Printf ("Got push event for %d" , event .Repo .URL )
109
+ handlePushEventApplyAfterMerge (gh , event )
110
+ if err != nil {
111
+ log .Printf ("handlePushEvent error: %v" , err )
112
+ c .String (http .StatusInternalServerError , err .Error ())
113
+ return
114
+ }
109
115
default :
110
116
log .Printf ("Unhandled event, event type %v" , reflect .TypeOf (event ))
111
117
}
@@ -384,62 +390,6 @@ func handleInstallationDeletedEvent(installation *github.InstallationEvent) erro
384
390
return nil
385
391
}
386
392
387
- func handlePushEvent (gh next_utils.GithubClientProvider , payload * github.PushEvent ) error {
388
- installationId := * payload .Installation .ID
389
- repoName := * payload .Repo .Name
390
- repoFullName := * payload .Repo .FullName
391
- repoOwner := * payload .Repo .Owner .Login
392
- cloneURL := * payload .Repo .CloneURL
393
- ref := * payload .Ref
394
- defaultBranch := * payload .Repo .DefaultBranch
395
-
396
- link , err := dbmodels .DB .GetGithubAppInstallationLink (installationId )
397
- if err != nil {
398
- log .Printf ("Error getting GetGithubAppInstallationLink: %v" , err )
399
- return fmt .Errorf ("error getting github app link" )
400
- }
401
-
402
- orgId := link .OrganizationID
403
- diggerRepoName := strings .ReplaceAll (repoFullName , "/" , "-" )
404
- repo , err := dbmodels .DB .GetRepo (orgId , diggerRepoName )
405
- if err != nil {
406
- log .Printf ("Error getting Repo: %v" , err )
407
- return fmt .Errorf ("error getting github app link" )
408
- }
409
- if repo == nil {
410
- log .Printf ("Repo not found: Org: %v | repo: %v" , orgId , diggerRepoName )
411
- return fmt .Errorf ("Repo not found: Org: %v | repo: %v" , orgId , diggerRepoName )
412
- }
413
-
414
- _ , token , err := next_utils .GetGithubService (gh , installationId , repoFullName , repoOwner , repoName )
415
- if err != nil {
416
- log .Printf ("Error getting github service: %v" , err )
417
- return fmt .Errorf ("error getting github service" )
418
- }
419
-
420
- var isMainBranch bool
421
- if strings .HasSuffix (ref , defaultBranch ) {
422
- isMainBranch = true
423
- } else {
424
- isMainBranch = false
425
- }
426
-
427
- err = utils .CloneGitRepoAndDoAction (cloneURL , defaultBranch , * token , func (dir string ) error {
428
- config , err := dg_configuration .LoadDiggerConfigYaml (dir , true , nil )
429
- if err != nil {
430
- log .Printf ("ERROR load digger.yml: %v" , err )
431
- return fmt .Errorf ("error loading digger.yml %v" , err )
432
- }
433
- dbmodels .DB .UpdateRepoDiggerConfig (link .OrganizationID , * config , repo , isMainBranch )
434
- return nil
435
- })
436
- if err != nil {
437
- return fmt .Errorf ("error while cloning repo: %v" , err )
438
- }
439
-
440
- return nil
441
- }
442
-
443
393
func handlePullRequestEvent (gh next_utils.GithubClientProvider , payload * github.PullRequestEvent , ciBackendProvider ci_backends.CiBackendProvider ) error {
444
394
installationId := * payload .Installation .ID
445
395
repoName := * payload .Repo .Name
0 commit comments