1
1
mirror of https://github.com/go-gitea/gitea synced 2025-08-06 09:38:21 +00:00

Add "View workflow file" to Actions list page (#34538)

This PR adds "View workflow file" to Actions list page, and replaces the
redundant link.

Related #34530

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
NorthRealm
2025-05-28 20:30:00 +08:00
committed by GitHub
parent b0936f4f41
commit 4cb0c641ce
7 changed files with 47 additions and 28 deletions

View File

@@ -31,16 +31,6 @@ import (
"github.com/nektos/act/pkg/model"
)
func getActionWorkflowPath(commit *git.Commit) string {
paths := []string{".gitea/workflows", ".github/workflows"}
for _, treePath := range paths {
if _, err := commit.SubTree(treePath); err == nil {
return treePath
}
}
return ""
}
func getActionWorkflowEntry(ctx *context.APIContext, commit *git.Commit, folder string, entry *git.TreeEntry) *api.ActionWorkflow {
cfgUnit := ctx.Repo.Repository.MustGetUnit(ctx, unit.TypeActions)
cfg := cfgUnit.ActionsConfig()
@@ -109,14 +99,12 @@ func ListActionWorkflows(ctx *context.APIContext) ([]*api.ActionWorkflow, error)
return nil, err
}
entries, err := actions.ListWorkflows(defaultBranchCommit)
folder, entries, err := actions.ListWorkflows(defaultBranchCommit)
if err != nil {
ctx.APIError(http.StatusNotFound, err.Error())
return nil, err
}
folder := getActionWorkflowPath(defaultBranchCommit)
workflows := make([]*api.ActionWorkflow, len(entries))
for i, entry := range entries {
workflows[i] = getActionWorkflowEntry(ctx, defaultBranchCommit, folder, entry)
@@ -185,7 +173,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
}
// get workflow entry from runTargetCommit
entries, err := actions.ListWorkflows(runTargetCommit)
_, entries, err := actions.ListWorkflows(runTargetCommit)
if err != nil {
return err
}