MCPcopy Index your code
hub / github.com/rilldata/rill / processGithubPush

Method processGithubPush

admin/github.go:362–411  ·  view source on GitHub ↗
(ctx context.Context, event *github.PushEvent)

Source from the content-addressed store, hash-verified

360}
361
362func (s *Service) processGithubPush(ctx context.Context, event *github.PushEvent) error {
363 // Find Rill project matching the repo that was pushed to
364 repo := event.GetRepo()
365 projects, err := s.DB.FindProjectsByGitRemote(ctx, *repo.CloneURL)
366 if err != nil {
367 if errors.Is(err, database.ErrNotFound) {
368 // App is installed on repo not currently deployed. Do nothing.
369 return nil
370 }
371 return err
372 }
373
374 // Parse the branch that was pushed to
375 // The format is refs/heads/main or refs/tags/v3.14.1
376 ref := event.GetRef()
377 _, branch, found := strings.Cut(ref, "refs/heads/")
378 if !found {
379 // We ignore tag pushes
380 return nil
381 }
382
383 // Iterate over all projects and trigger reconcile
384 var allErr error
385 for _, project := range projects {
386 // pull all deployments for the project
387 depls, err := s.DB.FindDeploymentsForProject(ctx, project.ID, "", branch)
388 if err != nil {
389 return err
390 }
391 for _, depl := range depls {
392 if depl.Editable {
393 // Don't trigger runtime reconcile for dev deployments, let the user manually pull changes to avoid any conflicts
394 continue
395 }
396 // Only trigger a reconcile for running/updating deployments.
397 // NOTE: Including "updating" here to avoid race conditions when there's a push and env config update happening simultaneously.
398 if depl.Status != database.DeploymentStatusRunning && depl.Status != database.DeploymentStatusUpdating {
399 s.Logger.Info("process github event: runtime reconcile not triggered, deployment is not ready", zap.String("project_id", project.ID), zap.String("deployment_id", depl.ID), zap.String("deployment_status", depl.Status.String()), observability.ZapCtx(ctx))
400 continue
401 }
402
403 err = s.TriggerParser(ctx, depl)
404 if err != nil {
405 allErr = errors.Join(allErr, fmt.Errorf("triggering parser for deployment %q: %w", depl.ID, err))
406 }
407 }
408 }
409
410 return allErr
411}
412
413func (s *Service) processGithubInstallationEvent(_ context.Context, event *github.InstallationEvent) error {
414 switch event.GetAction() {

Callers 1

ProcessGithubEventMethod · 0.95

Calls 8

TriggerParserMethod · 0.95
ZapCtxFunction · 0.92
InfoMethod · 0.80
StringMethod · 0.65
ErrorfMethod · 0.65
GetRepoMethod · 0.45

Tested by

no test coverage detected