@@ -33,9 +33,19 @@ import (
33
33
"xorm.io/builder"
34
34
)
35
35
36
+ func getRunIndex (ctx * context_module.Context ) int64 {
37
+ // if run param is "latest", get the latest run index
38
+ if ctx .PathParam ("run" ) == "latest" {
39
+ if run , _ := actions_model .GetLatestRun (ctx , ctx .Repo .Repository .ID ); run != nil {
40
+ return run .Index
41
+ }
42
+ }
43
+ return ctx .PathParamInt64 ("run" )
44
+ }
45
+
36
46
func View (ctx * context_module.Context ) {
37
47
ctx .Data ["PageIsActions" ] = true
38
- runIndex := ctx . PathParamInt64 ( "run" )
48
+ runIndex := getRunIndex ( ctx )
39
49
jobIndex := ctx .PathParamInt64 ("job" )
40
50
ctx .Data ["RunIndex" ] = runIndex
41
51
ctx .Data ["JobIndex" ] = jobIndex
@@ -130,7 +140,7 @@ type ViewStepLogLine struct {
130
140
131
141
func ViewPost (ctx * context_module.Context ) {
132
142
req := web .GetForm (ctx ).(* ViewRequest )
133
- runIndex := ctx . PathParamInt64 ( "run" )
143
+ runIndex := getRunIndex ( ctx )
134
144
jobIndex := ctx .PathParamInt64 ("job" )
135
145
136
146
current , jobs := getRunJobs (ctx , runIndex , jobIndex )
@@ -289,7 +299,7 @@ func ViewPost(ctx *context_module.Context) {
289
299
// Rerun will rerun jobs in the given run
290
300
// If jobIndexStr is a blank string, it means rerun all jobs
291
301
func Rerun (ctx * context_module.Context ) {
292
- runIndex := ctx . PathParamInt64 ( "run" )
302
+ runIndex := getRunIndex ( ctx )
293
303
jobIndexStr := ctx .PathParam ("job" )
294
304
var jobIndex int64
295
305
if jobIndexStr != "" {
@@ -379,7 +389,7 @@ func rerunJob(ctx *context_module.Context, job *actions_model.ActionRunJob, shou
379
389
}
380
390
381
391
func Logs (ctx * context_module.Context ) {
382
- runIndex := ctx . PathParamInt64 ( "run" )
392
+ runIndex := getRunIndex ( ctx )
383
393
jobIndex := ctx .PathParamInt64 ("job" )
384
394
385
395
job , _ := getRunJobs (ctx , runIndex , jobIndex )
@@ -428,7 +438,7 @@ func Logs(ctx *context_module.Context) {
428
438
}
429
439
430
440
func Cancel (ctx * context_module.Context ) {
431
- runIndex := ctx . PathParamInt64 ( "run" )
441
+ runIndex := getRunIndex ( ctx )
432
442
433
443
_ , jobs := getRunJobs (ctx , runIndex , - 1 )
434
444
if ctx .Written () {
@@ -469,7 +479,7 @@ func Cancel(ctx *context_module.Context) {
469
479
}
470
480
471
481
func Approve (ctx * context_module.Context ) {
472
- runIndex := ctx . PathParamInt64 ( "run" )
482
+ runIndex := getRunIndex ( ctx )
473
483
474
484
current , jobs := getRunJobs (ctx , runIndex , - 1 )
475
485
if ctx .Written () {
@@ -518,7 +528,6 @@ func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions
518
528
return nil , nil
519
529
}
520
530
run .Repo = ctx .Repo .Repository
521
-
522
531
jobs , err := actions_model .GetRunJobsByRunID (ctx , run .ID )
523
532
if err != nil {
524
533
ctx .Error (http .StatusInternalServerError , err .Error ())
@@ -550,7 +559,7 @@ type ArtifactsViewItem struct {
550
559
}
551
560
552
561
func ArtifactsView (ctx * context_module.Context ) {
553
- runIndex := ctx . PathParamInt64 ( "run" )
562
+ runIndex := getRunIndex ( ctx )
554
563
run , err := actions_model .GetRunByIndex (ctx , ctx .Repo .Repository .ID , runIndex )
555
564
if err != nil {
556
565
if errors .Is (err , util .ErrNotExist ) {
@@ -588,7 +597,7 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
588
597
return
589
598
}
590
599
591
- runIndex := ctx . PathParamInt64 ( "run" )
600
+ runIndex := getRunIndex ( ctx )
592
601
artifactName := ctx .PathParam ("artifact_name" )
593
602
594
603
run , err := actions_model .GetRunByIndex (ctx , ctx .Repo .Repository .ID , runIndex )
@@ -606,7 +615,7 @@ func ArtifactsDeleteView(ctx *context_module.Context) {
606
615
}
607
616
608
617
func ArtifactsDownloadView (ctx * context_module.Context ) {
609
- runIndex := ctx . PathParamInt64 ( "run" )
618
+ runIndex := getRunIndex ( ctx )
610
619
artifactName := ctx .PathParam ("artifact_name" )
611
620
612
621
run , err := actions_model .GetRunByIndex (ctx , ctx .Repo .Repository .ID , runIndex )
0 commit comments