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
This commit is contained in:
Nicolas
2026-05-25 10:25:22 +02:00
committed by GitHub
parent 6f4027a6be
commit bc6054b56d
3 changed files with 17 additions and 2 deletions
+14
View File
@@ -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)