monitorSpecificRun polls a specific run ID until it completes.
(ctx context.Context, runID int64)
| 470 | |
| 471 | // monitorSpecificRun polls a specific run ID until it completes. |
| 472 | func (p *Provider) monitorSpecificRun(ctx context.Context, runID int64) (*github.WorkflowRun, error) { |
| 473 | pollInterval := 20 * time.Second |
| 474 | maxWaitTime := 10 * time.Minute |
| 475 | startTime := time.Now() |
| 476 | |
| 477 | log.Printf("[GitHub Polling] Monitoring specific workflow run ID: %d", runID) |
| 478 | for time.Since(startTime) < maxWaitTime { |
| 479 | run, _, err := p.client.Actions.GetWorkflowRunByID(ctx, p.Owner, p.Repo, runID) |
| 480 | if err != nil { |
| 481 | log.Printf("[GitHub Polling] Error getting workflow run %d: %v. Retrying...", runID, err) |
| 482 | time.Sleep(pollInterval) |
| 483 | continue |
| 484 | } |
| 485 | |
| 486 | status := run.GetStatus() |
| 487 | log.Printf("[GitHub Polling] Workflow run %d status: %s, conclusion: %s", runID, status, run.GetConclusion()) |
| 488 | |
| 489 | if status == "completed" { |
| 490 | return run, nil |
| 491 | } else if status == "queued" || status == "in_progress" || status == "waiting" { |
| 492 | time.Sleep(pollInterval) |
| 493 | } else { |
| 494 | return run, fmt.Errorf("workflow run %d finished with unexpected status: %s, conclusion: %s. HTML URL: %s", runID, status, run.GetConclusion(), run.GetHTMLURL()) |
| 495 | } |
| 496 | time.Sleep(pollInterval) |
| 497 | } |
| 498 | return nil, fmt.Errorf("timed out after %s waiting for workflow run %d to complete", maxWaitTime, runID) |
| 499 | } |
| 500 | |
| 501 | // downloadAndParseArtifact downloads, unzips, and parses the artifact files. |
| 502 | // This function is now modified to downloadAndParseArtifactsBatch and handle an array of results. |