readWorkflowFile reads a workflow file from either filesystem
(filePath string, workflowsDir string)
| 40 | |
| 41 | // readWorkflowFile reads a workflow file from either filesystem |
| 42 | func readWorkflowFile(filePath string, workflowsDir string) ([]byte, string, error) { |
| 43 | // Using local filesystem |
| 44 | var fullPath string |
| 45 | |
| 46 | // Check if filePath is already an absolute path |
| 47 | if filepath.IsAbs(filePath) { |
| 48 | fullPath = filePath |
| 49 | } else { |
| 50 | // Join relative path with workflowsDir |
| 51 | fullPath = filepath.Join(workflowsDir, filePath) |
| 52 | } |
| 53 | |
| 54 | content, err := os.ReadFile(fullPath) |
| 55 | if err != nil { |
| 56 | return nil, "", fmt.Errorf("failed to read workflow file %s: %w", fullPath, err) |
| 57 | } |
| 58 | return content, fullPath, nil |
| 59 | } |
| 60 | |
| 61 | // GitHubWorkflow represents a workflow from GitHub API |
| 62 | type GitHubWorkflow struct { |