Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4cb0c64

Browse files
Add "View workflow file" to Actions list page (#34538)
This PR adds "View workflow file" to Actions list page, and replaces theredundant link.Related#34530---------Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
1 parentb0936f4 commit4cb0c64

File tree

7 files changed

+47
-28
lines changed

7 files changed

+47
-28
lines changed

‎modules/actions/workflows.go‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,23 @@ func IsWorkflow(path string) bool {
4343
returnstrings.HasPrefix(path,".gitea/workflows")||strings.HasPrefix(path,".github/workflows")
4444
}
4545

46-
funcListWorkflows(commit*git.Commit) (git.Entries,error) {
47-
tree,err:=commit.SubTree(".gitea/workflows")
46+
funcListWorkflows(commit*git.Commit) (string, git.Entries,error) {
47+
rpath:=".gitea/workflows"
48+
tree,err:=commit.SubTree(rpath)
4849
if_,ok:=err.(git.ErrNotExist);ok {
49-
tree,err=commit.SubTree(".github/workflows")
50+
rpath=".github/workflows"
51+
tree,err=commit.SubTree(rpath)
5052
}
5153
if_,ok:=err.(git.ErrNotExist);ok {
52-
returnnil,nil
54+
return"",nil,nil
5355
}
5456
iferr!=nil {
55-
returnnil,err
57+
return"",nil,err
5658
}
5759

5860
entries,err:=tree.ListEntriesRecursiveFast()
5961
iferr!=nil {
60-
returnnil,err
62+
return"",nil,err
6163
}
6264

6365
ret:=make(git.Entries,0,len(entries))
@@ -66,7 +68,7 @@ func ListWorkflows(commit *git.Commit) (git.Entries, error) {
6668
ret=append(ret,entry)
6769
}
6870
}
69-
returnret,nil
71+
returnrpath,ret,nil
7072
}
7173

7274
funcGetContentFromEntry(entry*git.TreeEntry) ([]byte,error) {
@@ -102,7 +104,7 @@ func DetectWorkflows(
102104
payload api.Payloader,
103105
detectSchedulebool,
104106
) ([]*DetectedWorkflow, []*DetectedWorkflow,error) {
105-
entries,err:=ListWorkflows(commit)
107+
_,entries,err:=ListWorkflows(commit)
106108
iferr!=nil {
107109
returnnil,nil,err
108110
}
@@ -147,7 +149,7 @@ func DetectWorkflows(
147149
}
148150

149151
funcDetectScheduledWorkflows(gitRepo*git.Repository,commit*git.Commit) ([]*DetectedWorkflow,error) {
150-
entries,err:=ListWorkflows(commit)
152+
_,entries,err:=ListWorkflows(commit)
151153
iferr!=nil {
152154
returnnil,err
153155
}

‎options/locale/locale_en-US.ini‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3815,6 +3815,7 @@ runs.expire_log_message = Logs have been purged because they were too old.
38153815
runs.delete = Delete workflow run
38163816
runs.delete.description = Are you sure you want to permanently delete this workflow run? This action cannot be undone.
38173817
runs.not_done = This workflow run is not done.
3818+
runs.view_workflow_file = View workflow file
38183819

38193820
workflow.disable = Disable Workflow
38203821
workflow.disable_success = Workflow'%s' disabled successfully.

‎routers/web/repo/actions/actions.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ func prepareWorkflowDispatchTemplate(ctx *context.Context, commit *git.Commit) (
126126

127127
varcurWorkflow*model.Workflow
128128

129-
entries,err:=actions.ListWorkflows(commit)
129+
_,entries,err:=actions.ListWorkflows(commit)
130130
iferr!=nil {
131131
ctx.ServerError("ListWorkflows",err)
132132
returnnil

‎routers/web/repo/actions/view.go‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,36 @@ func View(ctx *context_module.Context) {
6464
ctx.HTML(http.StatusOK,tplViewActions)
6565
}
6666

67+
funcViewWorkflowFile(ctx*context_module.Context) {
68+
runIndex:=getRunIndex(ctx)
69+
run,err:=actions_model.GetRunByIndex(ctx,ctx.Repo.Repository.ID,runIndex)
70+
iferr!=nil {
71+
ctx.NotFoundOrServerError("GetRunByIndex",func(errerror)bool {
72+
returnerrors.Is(err,util.ErrNotExist)
73+
},err)
74+
return
75+
}
76+
commit,err:=ctx.Repo.GitRepo.GetCommit(run.CommitSHA)
77+
iferr!=nil {
78+
ctx.NotFoundOrServerError("GetCommit",func(errerror)bool {
79+
returnerrors.Is(err,util.ErrNotExist)
80+
},err)
81+
return
82+
}
83+
rpath,entries,err:=actions.ListWorkflows(commit)
84+
iferr!=nil {
85+
ctx.ServerError("ListWorkflows",err)
86+
return
87+
}
88+
for_,entry:=rangeentries {
89+
ifentry.Name()==run.WorkflowID {
90+
ctx.Redirect(fmt.Sprintf("%s/src/commit/%s/%s/%s",ctx.Repo.RepoLink,url.PathEscape(run.CommitSHA),util.PathEscapeSegments(rpath),util.PathEscapeSegments(run.WorkflowID)))
91+
return
92+
}
93+
}
94+
ctx.NotFound(nil)
95+
}
96+
6797
typeLogCursorstruct {
6898
Stepint`json:"step"`
6999
Cursorint64`json:"cursor"`

‎routers/web/web.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1445,6 +1445,7 @@ func registerWebRoutes(m *web.Router) {
14451445
m.Post("/rerun",reqRepoActionsWriter,actions.Rerun)
14461446
m.Get("/logs",actions.Logs)
14471447
})
1448+
m.Get("/workflow",actions.ViewWorkflowFile)
14481449
m.Post("/cancel",reqRepoActionsWriter,actions.Cancel)
14491450
m.Post("/approve",reqRepoActionsWriter,actions.Approve)
14501451
m.Post("/delete",reqRepoActionsWriter,actions.Delete)

‎services/actions/workflow.go‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,6 @@ import (
3131
"github.com/nektos/act/pkg/model"
3232
)
3333

34-
funcgetActionWorkflowPath(commit*git.Commit)string {
35-
paths:= []string{".gitea/workflows",".github/workflows"}
36-
for_,treePath:=rangepaths {
37-
if_,err:=commit.SubTree(treePath);err==nil {
38-
returntreePath
39-
}
40-
}
41-
return""
42-
}
43-
4434
funcgetActionWorkflowEntry(ctx*context.APIContext,commit*git.Commit,folderstring,entry*git.TreeEntry)*api.ActionWorkflow {
4535
cfgUnit:=ctx.Repo.Repository.MustGetUnit(ctx,unit.TypeActions)
4636
cfg:=cfgUnit.ActionsConfig()
@@ -109,14 +99,12 @@ func ListActionWorkflows(ctx *context.APIContext) ([]*api.ActionWorkflow, error)
10999
returnnil,err
110100
}
111101

112-
entries,err:=actions.ListWorkflows(defaultBranchCommit)
102+
folder,entries,err:=actions.ListWorkflows(defaultBranchCommit)
113103
iferr!=nil {
114104
ctx.APIError(http.StatusNotFound,err.Error())
115105
returnnil,err
116106
}
117107

118-
folder:=getActionWorkflowPath(defaultBranchCommit)
119-
120108
workflows:=make([]*api.ActionWorkflow,len(entries))
121109
fori,entry:=rangeentries {
122110
workflows[i]=getActionWorkflowEntry(ctx,defaultBranchCommit,folder,entry)
@@ -185,7 +173,7 @@ func DispatchActionWorkflow(ctx reqctx.RequestContext, doer *user_model.User, re
185173
}
186174

187175
// get workflow entry from runTargetCommit
188-
entries,err:=actions.ListWorkflows(runTargetCommit)
176+
_,entries,err:=actions.ListWorkflows(runTargetCommit)
189177
iferr!=nil {
190178
returnerr
191179
}

‎templates/repo/actions/runs_list.tmpl‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,7 @@
3939
<div class="ui dropdown jump tw-p-2">
4040
{{svg "octicon-kebab-horizontal"}}
4141
<div class="menu flex-items-menu">
42-
<!-- TODO: This redundant link should be replaced by something else in future,
43-
because have not figured out how to add "View Workflow" or anything similar to GitHub.
44-
Related: https://github.com/go-gitea/gitea/pull/34530 -->
45-
<a class="item" href="{{$run.Link}}">{{svg "octicon-play"}}{{ctx.Locale.Tr "view"}}</a>
42+
<a class="item" href="{{$run.Link}}/workflow">{{svg "octicon-play"}}{{ctx.Locale.Tr "actions.runs.view_workflow_file"}}</a>
4643
{{if and $.AllowDeleteWorkflowRuns $run.Status.IsDone}}
4744
<a class="item link-action"
4845
data-url="{{$run.Link}}/delete"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp