@@ -32,8 +32,9 @@ import (
3232)
3333
3434const (
35- tplListActions templates.TplName = "repo/actions/list"
36- tplViewActions templates.TplName = "repo/actions/view"
35+ tplListActions templates.TplName = "repo/actions/list"
36+ tplDispatchInputsActions templates.TplName = "repo/actions/workflow_dispatch_inputs"
37+ tplViewActions templates.TplName = "repo/actions/view"
3738)
3839
3940type Workflow struct {
@@ -62,6 +63,10 @@ func MustEnableActions(ctx *context.Context) {
6263}
6364
6465func List (ctx * context.Context ) {
66+ renderListAndWorkflowDispatchTemplate (ctx , tplListActions , false )
67+ }
68+
69+ func renderListAndWorkflowDispatchTemplate (ctx * context.Context , tplName templates.TplName , useRef bool ) {
6570 ctx .Data ["Title" ] = ctx .Tr ("actions.actions" )
6671 ctx .Data ["PageIsActions" ] = true
6772 workflowID := ctx .FormString ("workflow" )
@@ -75,10 +80,34 @@ func List(ctx *context.Context) {
7580 ctx .ServerError ("IsEmpty" , err )
7681 return
7782 } else if ! empty {
78- commit , err := ctx .Repo .GitRepo .GetBranchCommit (ctx .Repo .Repository .DefaultBranch )
79- if err != nil {
80- ctx .ServerError ("GetBranchCommit" , err )
81- return
83+ var commit * git.Commit
84+ if useRef {
85+ ref := ctx .FormString ("ref" )
86+ if len (ref ) == 0 {
87+ ctx .ServerError ("ref" , nil )
88+ return
89+ }
90+ // get target commit of run from specified ref
91+ refName := git .RefName (ref )
92+ var err error
93+ if refName .IsTag () {
94+ commit , err = ctx .Repo .GitRepo .GetTagCommit (refName .TagName ())
95+ } else if refName .IsBranch () {
96+ commit , err = ctx .Repo .GitRepo .GetBranchCommit (refName .BranchName ())
97+ } else {
98+ ctx .ServerError ("git_ref_name_error" , nil )
99+ return
100+ }
101+ if err != nil {
102+ ctx .ServerError ("target_ref_not_exist" , err )
103+ return
104+ }
105+ } else {
106+ commit , err = ctx .Repo .GitRepo .GetBranchCommit (ctx .Repo .Repository .DefaultBranch )
107+ if err != nil {
108+ ctx .ServerError ("GetBranchCommit" , err )
109+ return
110+ }
82111 }
83112 entries , err := actions .ListWorkflows (commit )
84113 if err != nil {
@@ -265,7 +294,7 @@ func List(ctx *context.Context) {
265294 ctx .Data ["Page" ] = pager
266295 ctx .Data ["HasWorkflowsOrRuns" ] = len (workflows ) > 0 || len (runs ) > 0
267296
268- ctx .HTML (http .StatusOK , tplListActions )
297+ ctx .HTML (http .StatusOK , tplName )
269298}
270299
271300// loadIsRefDeleted loads the IsRefDeleted field for each run in the list.
0 commit comments