aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2024-04-08 23:08:26 +0900
committerGitHub <noreply@github.com>2024-04-08 22:08:26 +0800
commitd872ce006c0400edb10a05f7555f9b08070442e3 (patch)
treefe908976b6483f6081d890faf63c0b5b10559a2b /models
parent7d66b9ea65cc416046ec7075bc327932a4f2094f (diff)
downloadgitea-d872ce006c0400edb10a05f7555f9b08070442e3.tar.gz
gitea-d872ce006c0400edb10a05f7555f9b08070442e3.zip
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.
Diffstat (limited to 'models')
-rw-r--r--models/actions/task.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/models/actions/task.go b/models/actions/task.go
index 96a6d2e80c..1e279659c7 100644
--- a/models/actions/task.go
+++ b/models/actions/task.go
@@ -11,6 +11,7 @@ import (
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/container"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@@ -227,7 +228,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
if runner.RepoID != 0 {
jobCond = builder.Eq{"repo_id": runner.RepoID}
} else if runner.OwnerID != 0 {
- jobCond = builder.In("repo_id", builder.Select("id").From("repository").Where(builder.Eq{"owner_id": runner.OwnerID}))
+ jobCond = builder.In("repo_id", builder.Select("id").From("repository").
+ Join("INNER", "repo_unit", "`repository`.id = `repo_unit`.repo_id").
+ Where(builder.Eq{"`repository`.owner_id": runner.OwnerID, "`repo_unit`.type": unit.TypeActions}))
}
if jobCond.IsValid() {
jobCond = builder.In("run_id", builder.Select("id").From("action_run").Where(jobCond))