Skip to content

Commit d872ce0

Browse files
authored
Avoid running action when action unit is disabled after workflows detected (#30331)
Fix #30243 We only checking unit disabled when detecting workflows, but not in runner `FetchTask`. So if a workflow was detected when action unit is enabled, but disabled later, `FetchTask` will still return these detected actions. Global setting: repo.ENABLED and repository.`DISABLED_REPO_UNITS` will not effect this.
1 parent 7d66b9e commit d872ce0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

models/actions/task.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
auth_model "code.gitea.io/gitea/models/auth"
1313
"code.gitea.io/gitea/models/db"
14+
"code.gitea.io/gitea/models/unit"
1415
"code.gitea.io/gitea/modules/container"
1516
"code.gitea.io/gitea/modules/log"
1617
"code.gitea.io/gitea/modules/setting"
@@ -227,7 +228,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
227228
if runner.RepoID != 0 {
228229
jobCond = builder.Eq{"repo_id": runner.RepoID}
229230
} else if runner.OwnerID != 0 {
230-
jobCond = builder.In("repo_id", builder.Select("id").From("repository").Where(builder.Eq{"owner_id": runner.OwnerID}))
231+
jobCond = builder.In("repo_id", builder.Select("id").From("repository").
232+
Join("INNER", "repo_unit", "`repository`.id = `repo_unit`.repo_id").
233+
Where(builder.Eq{"`repository`.owner_id": runner.OwnerID, "`repo_unit`.type": unit.TypeActions}))
231234
}
232235
if jobCond.IsValid() {
233236
jobCond = builder.In("run_id", builder.Select("id").From("action_run").Where(jobCond))

0 commit comments

Comments
 (0)