@@ -6,7 +6,7 @@ package actions
66import (
77 "fmt"
88 "net/http"
9- "os "
9+ "path "
1010 "strings"
1111
1212 actions_model "code.gitea.io/gitea/models/actions"
@@ -53,14 +53,14 @@ func getActionWorkflowPath(commit *git.Commit) string {
5353 return ""
5454}
5555
56- func getActionWorkflowEntry (ctx * context.APIContext , commit * git.Commit , entry * git.TreeEntry ) * api.ActionWorkflow {
56+ func getActionWorkflowEntry (ctx * context.APIContext , commit * git.Commit , folder string , entry * git.TreeEntry ) * api.ActionWorkflow {
5757 cfgUnit := ctx .Repo .Repository .MustGetUnit (ctx , unit .TypeActions )
5858 cfg := cfgUnit .ActionsConfig ()
5959
6060 defaultBranch , _ := commit .GetBranchName ()
6161
6262 URL := fmt .Sprintf ("%s/actions/workflows/%s" , ctx .Repo .Repository .APIURL (), entry .Name ())
63- HTMLURL := fmt .Sprintf ("%s/src/branch/%s/%s/%s" , ctx .Repo .Repository .HTMLURL (ctx ), defaultBranch , getActionWorkflowPath ( commit ) , entry .Name ())
63+ HTMLURL := fmt .Sprintf ("%s/src/branch/%s/%s/%s" , ctx .Repo .Repository .HTMLURL (ctx ), defaultBranch , folder , entry .Name ())
6464 badgeURL := fmt .Sprintf ("%s/actions/workflows/%s/badge.svg?branch=%s" , ctx .Repo .Repository .HTMLURL (ctx ), entry .Name (), ctx .Repo .Repository .DefaultBranch )
6565
6666 // See https://docs.github.com/en/rest/actions/workflows?apiVersion=2022-11-28#get-a-workflow
@@ -75,13 +75,6 @@ func getActionWorkflowEntry(ctx *context.APIContext, commit *git.Commit, entry *
7575 state = "disabled_manually"
7676 }
7777
78- // Currently, the NodeID returns the hostname of the server since, as far as I know, Gitea does not have a parameter
79- // similar to an instance ID.
80- hostname , err := os .Hostname ()
81- if err != nil {
82- hostname = "unknown"
83- }
84-
8578 // The CreatedAt and UpdatedAt fields currently reflect the timestamp of the latest commit, which can later be refined
8679 // by retrieving the first and last commits for the file history. The first commit would indicate the creation date,
8780 // while the last commit would represent the modification date. The DeletedAt could be determined by identifying
@@ -92,9 +85,8 @@ func getActionWorkflowEntry(ctx *context.APIContext, commit *git.Commit, entry *
9285
9386 return & api.ActionWorkflow {
9487 ID : entry .Name (),
95- NodeID : hostname ,
9688 Name : entry .Name (),
97- Path : entry .Name (),
89+ Path : path . Join ( folder , entry .Name () ),
9890 State : state ,
9991 CreatedAt : createdAt ,
10092 UpdatedAt : updatedAt ,
@@ -135,9 +127,11 @@ func ListActionWorkflows(ctx *context.APIContext) ([]*api.ActionWorkflow, error)
135127 return nil , err
136128 }
137129
130+ folder := getActionWorkflowPath (defaultBranchCommit )
131+
138132 workflows := make ([]* api.ActionWorkflow , len (entries ))
139133 for i , entry := range entries {
140- workflows [i ] = getActionWorkflowEntry (ctx , defaultBranchCommit , entry )
134+ workflows [i ] = getActionWorkflowEntry (ctx , defaultBranchCommit , folder , entry )
141135 }
142136
143137 return workflows , nil
0 commit comments