Skip to content

Commit

Permalink
Fix schedule actions still running even if workflow disalbed (#26939)
Browse files Browse the repository at this point in the history
Fix #26782
  • Loading branch information
lunny authored Sep 7, 2023
1 parent 1ee4882 commit d1dca38
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions services/actions/schedule_tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

actions_model "code.gitea.io/gitea/models/actions"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/timeutil"
webhook_module "code.gitea.io/gitea/modules/webhook"
Expand Down Expand Up @@ -44,6 +45,10 @@ func startTasks(ctx context.Context) error {
return fmt.Errorf("find specs: %w", err)
}

if err := specs.LoadRepos(); err != nil {
return fmt.Errorf("LoadRepos: %w", err)
}

// Loop through each spec and create a schedule task for it
for _, row := range specs {
// cancel running jobs if the event is push
Expand All @@ -59,6 +64,11 @@ func startTasks(ctx context.Context) error {
}
}

cfg := row.Repo.MustGetUnit(ctx, unit.TypeActions).ActionsConfig()
if cfg.IsWorkflowDisabled(row.Schedule.WorkflowID) {
continue
}

if err := CreateScheduleTask(ctx, row.Schedule); err != nil {
log.Error("CreateScheduleTask: %v", err)
return err
Expand Down

0 comments on commit d1dca38

Please sign in to comment.