Skip to content

Commit ea4f58c

Browse files
committed
add a warning
1 parent 4ebd227 commit ea4f58c

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3627,6 +3627,7 @@ runs.scheduled = Scheduled
36273627
runs.pushed_by = pushed by
36283628
runs.invalid_workflow_helper = Workflow config file is invalid. Please check your config file: %s
36293629
runs.no_matching_online_runner_helper = No matching online runner with label: %s
3630+
runs.no_job_without_needs = The workflow must contain at least one job with no dependencies.
36303631
runs.actor = Actor
36313632
runs.status = Status
36323633
runs.actors_no_select = All actors

routers/web/repo/actions/actions.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,13 @@ func List(ctx *context.Context) {
104104
workflows = append(workflows, workflow)
105105
continue
106106
}
107-
// Check whether have matching runner
107+
// The workflow must contain at least one job without "needs". Otherwise, a deadlock will occur and no jobs will be able to run.
108+
hasJobWithoutNeeds := false
109+
// Check whether have matching runner and a job without "needs"
108110
for _, j := range wf.Jobs {
111+
if !hasJobWithoutNeeds && len(j.Needs()) == 0 {
112+
hasJobWithoutNeeds = true
113+
}
109114
runsOnList := j.RunsOn()
110115
for _, ro := range runsOnList {
111116
if strings.Contains(ro, "${{") {
@@ -123,6 +128,9 @@ func List(ctx *context.Context) {
123128
break
124129
}
125130
}
131+
if !hasJobWithoutNeeds {
132+
workflow.ErrMsg = ctx.Locale.TrString("actions.runs.no_job_without_needs")
133+
}
126134
workflows = append(workflows, workflow)
127135
}
128136
}

0 commit comments

Comments
 (0)