From bc6054b56d61a02bec7d77249a5131f7b6facc97 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 25 May 2026 10:25:22 +0200 Subject: [PATCH] enhance(actions): show workflow name from YAML instead of filename (#37833) Use the workflow's YAML `name:` field for display in the workflow sidebar and run list, falling back to the filename when no name is set. Closes https://github.com/go-gitea/gitea/issues/31458 Closes https://github.com/go-gitea/gitea/issues/25912 Closes https://github.com/go-gitea/gitea/pull/31474 --- routers/web/repo/actions/actions.go | 14 ++++++++++++++ templates/repo/actions/list.tmpl | 2 +- templates/repo/actions/runs_list.tmpl | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/actions/actions.go b/routers/web/repo/actions/actions.go index 5c454dac241..1e6a839ee76 100644 --- a/routers/web/repo/actions/actions.go +++ b/routers/web/repo/actions/actions.go @@ -44,6 +44,14 @@ type WorkflowInfo struct { Workflow *act_model.Workflow } +// DisplayName returns the workflow name from the YAML file if present, otherwise the filename. +func (w WorkflowInfo) DisplayName() string { + if w.Workflow != nil && w.Workflow.Name != "" { + return w.Workflow.Name + } + return w.Entry.Name() +} + // MustEnableActions check if actions are enabled in settings func MustEnableActions(ctx *context.Context) { if !setting.Actions.Enabled { @@ -341,6 +349,12 @@ func prepareWorkflowList(ctx *context.Context, workflows []WorkflowInfo) { ctx.Data["Runs"] = runs + workflowNames := make(map[string]string, len(workflows)) + for _, wf := range workflows { + workflowNames[wf.Entry.Name()] = wf.DisplayName() + } + ctx.Data["WorkflowNames"] = workflowNames + actors, err := actions_model.GetActors(ctx, ctx.Repo.Repository.ID) if err != nil { ctx.ServerError("GetActors", err) diff --git a/templates/repo/actions/list.tmpl b/templates/repo/actions/list.tmpl index 4fbc58592a0..7cc92efc3a4 100644 --- a/templates/repo/actions/list.tmpl +++ b/templates/repo/actions/list.tmpl @@ -11,7 +11,7 @@ {{ctx.Locale.Tr "actions.runs.all_workflows"}} {{range .workflows}} - {{.Entry.Name}} + {{.DisplayName}} {{if .ErrMsg}} {{svg "octicon-alert" 16 "tw-text-red"}} diff --git a/templates/repo/actions/runs_list.tmpl b/templates/repo/actions/runs_list.tmpl index e3a73c97392..edc167e706b 100644 --- a/templates/repo/actions/runs_list.tmpl +++ b/templates/repo/actions/runs_list.tmpl @@ -21,7 +21,8 @@ {{end}}
- {{if not $.CurWorkflow}}{{$run.WorkflowID}} {{end}}#{{$run.Index}}: + {{$workflowName := index $.WorkflowNames $run.WorkflowID}} + {{if not $.CurWorkflow}}{{if $workflowName}}{{$workflowName}}{{else}}{{$run.WorkflowID}}{{end}} {{end}}#{{$run.Index}}: {{- if $run.ScheduleID -}} {{ctx.Locale.Tr "actions.runs.scheduled"}}