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)
| 203 | // --repo is specified. Local-only fields (EngineID, Compiled, TimeRemaining, Labels, |
| 204 | // On) are not available for remote repositories and are omitted from results. |
| 205 | func 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 | |
| 243 | func 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) |