MCPcopy Index your code
hub / github.com/cli/cli / ListArtifacts

Function ListArtifacts

pkg/cmd/run/shared/artifacts.go:25–51  ·  view source on GitHub ↗
(httpClient *http.Client, repo ghrepo.Interface, runID string)

Source from the content-addressed store, hash-verified

23}
24
25func ListArtifacts(httpClient *http.Client, repo ghrepo.Interface, runID string) ([]Artifact, error) {
26 var results []Artifact
27
28 perPage := 100
29 path := fmt.Sprintf("repos/%s/%s/actions/artifacts?per_page=%d", repo.RepoOwner(), repo.RepoName(), perPage)
30 if runID != "" {
31 path = fmt.Sprintf("repos/%s/%s/actions/runs/%s/artifacts?per_page=%d", repo.RepoOwner(), repo.RepoName(), runID, perPage)
32 }
33
34 url := fmt.Sprintf("%s%s", ghinstance.RESTPrefix(repo.RepoHost()), path)
35
36 for {
37 var payload artifactsPayload
38 nextURL, err := apiGet(httpClient, url, &payload)
39 if err != nil {
40 return nil, err
41 }
42 results = append(results, payload.Artifacts...)
43
44 if nextURL == "" {
45 break
46 }
47 url = nextURL
48 }
49
50 return results, nil
51}
52
53func apiGet(httpClient *http.Client, url string, data interface{}) (string, error) {
54 req, err := http.NewRequest("GET", url, nil)

Callers 3

runViewFunction · 0.92
ListMethod · 0.92

Calls 5

RESTPrefixFunction · 0.92
apiGetFunction · 0.85
RepoOwnerMethod · 0.65
RepoNameMethod · 0.65
RepoHostMethod · 0.65

Tested by 1