fetchWorkflowRunMetadata fetches metadata for a single workflow run
(ctx context.Context, runID int64, owner, repo, hostname string, verbose bool)
| 1142 | |
| 1143 | // fetchWorkflowRunMetadata fetches metadata for a single workflow run |
| 1144 | func fetchWorkflowRunMetadata(ctx context.Context, runID int64, owner, repo, hostname string, verbose bool) (WorkflowRun, error) { |
| 1145 | args := buildWorkflowRunMetadataArgs(runID, owner, repo, hostname) |
| 1146 | if verbose { |
| 1147 | fmt.Fprintln(os.Stderr, console.FormatInfoMessage("Executing: gh "+strings.Join(args, " "))) |
| 1148 | } |
| 1149 | output, err := workflow.RunGHCombinedContext(ctx, "Fetching run metadata...", args...) |
| 1150 | if err != nil { |
| 1151 | if verbose { |
| 1152 | fmt.Fprintln(os.Stderr, console.FormatVerboseMessage(string(output))) |
| 1153 | } |
| 1154 | return WorkflowRun{}, classifyWorkflowRunMetadataError(runID, err, output) |
| 1155 | } |
| 1156 | var run WorkflowRun |
| 1157 | if err := json.Unmarshal(output, &run); err != nil { |
| 1158 | return WorkflowRun{}, fmt.Errorf("failed to parse run metadata: %w", err) |
| 1159 | } |
| 1160 | resolveWorkflowRunDisplayName(ctx, &run, owner, repo, hostname) |
| 1161 | return run, nil |
| 1162 | } |
| 1163 | |
| 1164 | func buildWorkflowRunMetadataArgs(runID int64, owner, repo, hostname string) []string { |
| 1165 | endpoint := fmt.Sprintf("repos/{owner}/{repo}/actions/runs/%d", runID) |
no test coverage detected