@@ -17,6 +17,7 @@ import (
17
17
"code.gitea.io/gitea/routers/api/v1/utils"
18
18
actions_service "code.gitea.io/gitea/services/actions"
19
19
"code.gitea.io/gitea/services/context"
20
+ "code.gitea.io/gitea/services/convert"
20
21
secret_service "code.gitea.io/gitea/services/secrets"
21
22
)
22
23
@@ -517,3 +518,68 @@ type Action struct{}
517
518
func NewAction () actions_service.API {
518
519
return Action {}
519
520
}
521
+
522
+ // ListActionTasks list all the actions of a repository
523
+ func ListActionTasks (ctx * context.APIContext ) {
524
+ // swagger:operation GET /repos/{owner}/{repo}/actions/tasks repository ListActionTasks
525
+ // ---
526
+ // summary: List a repository's action tasks
527
+ // produces:
528
+ // - application/json
529
+ // parameters:
530
+ // - name: owner
531
+ // in: path
532
+ // description: owner of the repo
533
+ // type: string
534
+ // required: true
535
+ // - name: repo
536
+ // in: path
537
+ // description: name of the repo
538
+ // type: string
539
+ // required: true
540
+ // - name: page
541
+ // in: query
542
+ // description: page number of results to return (1-based)
543
+ // type: integer
544
+ // - name: limit
545
+ // in: query
546
+ // description: page size of results, default maximum page size is 50
547
+ // type: integer
548
+ // responses:
549
+ // "200":
550
+ // "$ref": "#/responses/TasksList"
551
+ // "400":
552
+ // "$ref": "#/responses/error"
553
+ // "403":
554
+ // "$ref": "#/responses/forbidden"
555
+ // "404":
556
+ // "$ref": "#/responses/notFound"
557
+ // "409":
558
+ // "$ref": "#/responses/conflict"
559
+ // "422":
560
+ // "$ref": "#/responses/validationError"
561
+
562
+ tasks , total , err := db .FindAndCount [actions_model.ActionTask ](ctx , & actions_model.FindTaskOptions {
563
+ ListOptions : utils .GetListOptions (ctx ),
564
+ RepoID : ctx .Repo .Repository .ID ,
565
+ })
566
+ if err != nil {
567
+ ctx .Error (http .StatusInternalServerError , "ListActionTasks" , err )
568
+ return
569
+ }
570
+
571
+ res := new (api.ActionTaskResponse )
572
+ res .TotalCount = total
573
+
574
+ res .Entries = make ([]* api.ActionTask , len (tasks ))
575
+ for i := range tasks {
576
+ convertedTask , err := convert .ToActionTask (ctx , tasks [i ])
577
+ if err != nil {
578
+ ctx .Error (http .StatusInternalServerError , "ToActionTask" , err )
579
+ return
580
+ }
581
+ res .Entries [i ] = convertedTask
582
+ }
583
+
584
+ ctx .JSON (http .StatusOK , & res )
585
+ }
0 commit comments