forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttp.go
More file actions
31 lines (24 loc) · 765 Bytes
/
http.go
File metadata and controls
31 lines (24 loc) · 765 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package view
import (
"fmt"
"github.com/cli/cli/v2/api"
"github.com/cli/cli/v2/internal/ghrepo"
runShared "github.com/cli/cli/v2/pkg/cmd/run/shared"
"github.com/cli/cli/v2/pkg/cmd/workflow/shared"
)
type workflowRuns struct {
Total int
Runs []runShared.Run
}
func getWorkflowRuns(client *api.Client, repo ghrepo.Interface, workflow *shared.Workflow) (workflowRuns, error) {
var wr workflowRuns
var result runShared.RunsPayload
path := fmt.Sprintf("repos/%s/actions/workflows/%d/runs?per_page=%d&page=%d", ghrepo.FullName(repo), workflow.ID, 5, 1)
err := client.REST(repo.RepoHost(), "GET", path, nil, &result)
if err != nil {
return wr, err
}
wr.Total = result.TotalCount
wr.Runs = append(wr.Runs, result.WorkflowRuns...)
return wr, nil
}