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

Function buildRemoteWorkflowStatuses

pkg/cli/status_command.go:205–241  ·  view source on GitHub ↗

buildRemoteWorkflowStatuses constructs workflow statuses from GitHub API data when --repo is specified. Local-only fields (EngineID, Compiled, TimeRemaining, Labels, On) are not available for remote repositories and are omitted from results.

(pattern string, githubWorkflows map[string]*GitHubWorkflow, latestRunsByWorkflow map[string]*WorkflowRun)

Source from the content-addressed store, hash-verified

203// --repo is specified. Local-only fields (EngineID, Compiled, TimeRemaining, Labels,
204// On) are not available for remote repositories and are omitted from results.
205func buildRemoteWorkflowStatuses(pattern string, githubWorkflows map[string]*GitHubWorkflow, latestRunsByWorkflow map[string]*WorkflowRun) []WorkflowStatus {
206 statuses := make([]WorkflowStatus, 0, len(githubWorkflows))
207 for name, wf := range githubWorkflows {
208 // Skip if pattern specified and doesn't match
209 if pattern != "" && !strings.Contains(strings.ToLower(name), strings.ToLower(pattern)) {
210 continue
211 }
212
213 status := wf.State
214 if wf.State == "disabled_manually" {
215 status = "disabled"
216 }
217
218 var runID int64
219 var runStatus, runConclusion string
220 if latestRunsByWorkflow != nil {
221 if run, exists := latestRunsByWorkflow[name]; exists {
222 runID = run.DatabaseID
223 runStatus = run.Status
224 runConclusion = run.Conclusion
225 }
226 }
227
228 statuses = append(statuses, WorkflowStatus{
229 // Remote workflow status only includes the workflow name here; the
230 // GitHub Actions API response does not provide list metadata fields.
231 WorkflowListItem: WorkflowListItem{
232 Workflow: name,
233 },
234 Status: status,
235 RunID: runID,
236 RunStatus: runStatus,
237 RunConclusion: runConclusion,
238 })
239 }
240 return statuses
241}
242
243func StatusWorkflows(pattern string, verbose bool, jsonOutput bool, ref string, labelFilter string, repoOverride string) error {
244 statusLog.Printf("Checking workflow status: pattern=%s, jsonOutput=%v, ref=%s, labelFilter=%s, repo=%s", pattern, jsonOutput, ref, labelFilter, repoOverride)

Callers 2

GetWorkflowStatusesFunction · 0.85

Calls 1

ToLowerMethod · 0.80

Tested by 1