forked from fileformat/ghashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
workflows.go
47 lines (42 loc) · 999 Bytes
/
workflows.go
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package main
import (
"context"
"fmt"
"strings"
github "github.com/google/go-github/v58/github"
)
func GetWorkflowsForRepo(client *github.Client, repo *github.Repository) ([]*github.Workflow, error) {
opt := &github.ListOptions{PerPage: 50}
ctx := context.Background()
var allWorkflows []*github.Workflow
for {
workflows, resp, err := client.Actions.ListWorkflows(ctx, *repo.Owner.Login, *repo.Name, opt)
if err != nil {
return nil, err
}
for _, workflow := range workflows.Workflows {
if Inactive && *workflow.State != "active" {
continue
}
if len(IncludeSet) > 0 {
_, ok := IncludeSet[strings.ToLower(*workflow.Name)]
if !ok {
continue
}
}
if len(ExcludeSet) > 0 {
_, ok := ExcludeSet[strings.ToLower(*workflow.Name)]
if ok {
continue
}
}
allWorkflows = append(allWorkflows, workflow)
}
if resp.NextPage == 0 {
break
}
fmt.Printf("Paging...\n")
opt.Page = resp.NextPage
}
return allWorkflows, nil
}