loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Interpolate runs-on with variables when scheduling tasks (#30640)

Follow #29468
1. Interpolate runs-on with variables when scheduling tasks.
2. The `GetVariablesOfRun` function will check if the `Repo` of the run
is nil.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
(cherry picked from commit 2f6b1c46a1a4a90f56ca0f3ad7840e8e70daeab5)

Conflicts:
services/actions/schedule_tasks.go
trivial conflict because of 'Add vars context to cron jobs (#3059)'

authored by

sillyguodong
Giteabot
and committed by
Earl Warren
561a7cf5 a72b660c

+23 -11
+16 -6
models/actions/run.go
··· 98 98 return nil 99 99 } 100 100 101 - if run.Repo == nil { 102 - repo, err := repo_model.GetRepositoryByID(ctx, run.RepoID) 103 - if err != nil { 104 - return err 105 - } 106 - run.Repo = repo 101 + if err := run.LoadRepo(ctx); err != nil { 102 + return err 107 103 } 104 + 108 105 if err := run.Repo.LoadAttributes(ctx); err != nil { 109 106 return err 110 107 } ··· 117 114 run.TriggerUser = u 118 115 } 119 116 117 + return nil 118 + } 119 + 120 + func (run *ActionRun) LoadRepo(ctx context.Context) error { 121 + if run == nil || run.Repo != nil { 122 + return nil 123 + } 124 + 125 + repo, err := repo_model.GetRepositoryByID(ctx, run.RepoID) 126 + if err != nil { 127 + return err 128 + } 129 + run.Repo = repo 120 130 return nil 121 131 } 122 132
+5
models/actions/variable.go
··· 92 92 func GetVariablesOfRun(ctx context.Context, run *ActionRun) (map[string]string, error) { 93 93 variables := map[string]string{} 94 94 95 + if err := run.LoadRepo(ctx); err != nil { 96 + log.Error("LoadRepo: %v", err) 97 + return nil, err 98 + } 99 + 95 100 // Global 96 101 globalVariables, err := db.Find[ActionVariable](ctx, FindVariablesOpts{}) 97 102 if err != nil {
+2 -5
services/actions/schedule_tasks.go
··· 132 132 Status: actions_model.StatusWaiting, 133 133 } 134 134 135 - if err := run.LoadAttributes(ctx); err != nil { 136 - log.Error("LoadAttributes: %v", err) 137 - } 138 - 139 135 vars, err := actions_model.GetVariablesOfRun(ctx, run) 140 136 if err != nil { 141 - log.Error("GetVariablesOfSchedule: %v", err) 137 + log.Error("GetVariablesOfRun: %v", err) 138 + return err 142 139 } 143 140 144 141 // Parse the workflow specification from the cron schedule