MCPcopy Create free account
hub / github.com/github/gh-aw / listWorkflowRunsWithPagination

Function listWorkflowRunsWithPagination

pkg/cli/logs_github_api.go:192–371  ·  view source on GitHub ↗

listWorkflowRunsWithPagination fetches workflow runs from GitHub Actions using the GitHub CLI. This function retrieves workflow runs with pagination support and applies various filters as specified in the ListWorkflowRunsOptions. Returns: - []WorkflowRun: filtered list of workflow runs - int: tota

(opts ListWorkflowRunsOptions)

Source from the content-addressed store, hash-verified

190//
191// The processedCount and targetCount parameters are used to display progress in the spinner message.
192func listWorkflowRunsWithPagination(opts ListWorkflowRunsOptions) ([]WorkflowRun, int, error) {
193 logsGitHubAPILog.Printf("Listing workflow runs: workflow=%s, limit=%d, startDate=%s, endDate=%s, ref=%s", opts.WorkflowName, opts.Limit, opts.StartDate, opts.EndDate, opts.Ref)
194 args := []string{"run", "list", "--json", "databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle"}
195
196 // Add filters
197 if opts.WorkflowName != "" {
198 args = append(args, "--workflow", opts.WorkflowName)
199 }
200 if opts.Status != "" {
201 args = append(args, "--status", opts.Status)
202 }
203 if opts.Limit > 0 {
204 args = append(args, "--limit", strconv.Itoa(opts.Limit))
205 }
206 // Build a single --created filter that covers the full date range.
207 // gh run list's --created flag is a single string (not a slice); passing it
208 // multiple times only keeps the last value and silently drops earlier bounds.
209 // buildCreatedFilter combines all bounds into one expression so that every
210 // bound is honoured.
211 if createdFilter := buildCreatedFilter(opts.StartDate, opts.EndDate, opts.BeforeDate); createdFilter != "" {
212 args = append(args, "--created", createdFilter)
213 }
214 // Add ref filter (uses --branch flag which also works for tags)
215 if opts.Ref != "" {
216 args = append(args, "--branch", opts.Ref)
217 }
218 // Add repo filter
219 if opts.RepoOverride != "" {
220 args = append(args, "--repo", opts.RepoOverride)
221 }
222
223 if opts.Verbose {
224 fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Executing: gh "+strings.Join(args, " ")))
225 }
226
227 // Start spinner for network operation
228 spinnerMsg := workflowRunsSpinnerMessage(opts)
229 spinner := console.NewSpinner(spinnerMsg)
230 if !opts.Verbose {
231 spinner.Start()
232 }
233
234 cmdCtx := opts.Context
235 if cmdCtx == nil {
236 cmdCtx = context.Background()
237 }
238 cmd := workflow.ExecGHContext(cmdCtx, args...)
239 output, err := cmd.CombinedOutput()
240
241 if err != nil {
242 // Stop spinner on error
243 if !opts.Verbose {
244 spinner.Stop()
245 }
246
247 // Extract detailed error information including exit code
248 var exitCode int
249 var exitErr *exec.ExitError

Callers 4

evaluateForecastFunction · 0.85
fetchWorkflowRunsFunction · 0.85
DownloadWorkflowLogsFunction · 0.85

Calls 15

FormatInfoMessageFunction · 0.92
NewSpinnerFunction · 0.92
ExecGHContextFunction · 0.92
FormatVerboseMessageFunction · 0.92
buildCreatedFilterFunction · 0.85
isPermissionErrorStrFunction · 0.85
getAgenticWorkflowNamesFunction · 0.85
BackgroundMethod · 0.80
ToLowerMethod · 0.80
PrintfMethod · 0.45
StartMethod · 0.45

Tested by 1