(ctx context.Context, event *github.PushEvent)
| 360 | } |
| 361 | |
| 362 | func (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 | |
| 413 | func (s *Service) processGithubInstallationEvent(_ context.Context, event *github.InstallationEvent) error { |
| 414 | switch event.GetAction() { |
no test coverage detected