findRemoteWorkflowFilenameForExperiment lists .md files in .github/workflows/ via the GitHub API and returns the basename (without .md) of the first file whose sanitized name matches experimentName. This mirrors findWorkflowFileForExperiment for remote repos. Returns "" when the directory cannot be
(repoOverride, experimentName string)
| 410 | // matches experimentName. This mirrors findWorkflowFileForExperiment for remote repos. |
| 411 | // Returns "" when the directory cannot be listed or no match is found. |
| 412 | func findRemoteWorkflowFilenameForExperiment(repoOverride, experimentName string) string { |
| 413 | args := []string{"api", |
| 414 | "repos/{owner}/{repo}/contents/.github/workflows", |
| 415 | "--jq", `[.[] | select(.name | endswith(".md")) | .name]`, |
| 416 | "--repo", repoOverride, |
| 417 | } |
| 418 | cmd := workflow.ExecGH(args...) |
| 419 | out, err := cmd.Output() |
| 420 | if err != nil { |
| 421 | experimentsLog.Printf("Failed to list remote workflow files from %s: %v", repoOverride, err) |
| 422 | return "" |
| 423 | } |
| 424 | |
| 425 | var filenames []string |
| 426 | if err := json.Unmarshal(out, &filenames); err != nil { |
| 427 | experimentsLog.Printf("Failed to parse remote workflow file listing: %v", err) |
| 428 | return "" |
| 429 | } |
| 430 | |
| 431 | return matchWorkflowFilenameByExperiment(filenames, experimentName) |
| 432 | } |
| 433 | |
| 434 | // matchWorkflowFilenameByExperiment returns the basename (without .md) of the first file in |
| 435 | // filenames whose sanitized name matches experimentName. Returns "" when no match is found. |
no test coverage detected