getSecretRequirements discovers all workflows and collects their required secrets
(engineFilter string)
| 122 | |
| 123 | // getSecretRequirements discovers all workflows and collects their required secrets |
| 124 | func getSecretRequirements(engineFilter string) ([]SecretRequirement, error) { |
| 125 | tokensBootstrapLog.Printf("Discovering workflows (engine filter: %s)", engineFilter) |
| 126 | |
| 127 | var allRequirements []SecretRequirement |
| 128 | |
| 129 | // If engine is explicitly specified, we can bootstrap without workflows |
| 130 | if engineFilter != "" { |
| 131 | tokensBootstrapLog.Printf("Engine explicitly specified, bootstrapping for %s regardless of workflows", engineFilter) |
| 132 | // Get engine-specific secrets and system secrets (including optional) |
| 133 | allRequirements = getSecretRequirementsForEngine(engineFilter, true, true) |
| 134 | } else { |
| 135 | // Discover workflow files |
| 136 | workflowFiles, err := getMarkdownWorkflowFiles("") |
| 137 | if err != nil { |
| 138 | return nil, fmt.Errorf("failed to discover workflows: %w", err) |
| 139 | } |
| 140 | |
| 141 | if len(workflowFiles) == 0 { |
| 142 | return nil, errors.New("no workflow files found in .github/workflows/") |
| 143 | } |
| 144 | |
| 145 | tokensBootstrapLog.Printf("Found %d workflow files, extracting secrets", len(workflowFiles)) |
| 146 | |
| 147 | // Use getRequiredSecretsForWorkflows to collect and deduplicate secrets |
| 148 | allRequirements = getSecretsRequirementsForWorkflows(workflowFiles) |
| 149 | } |
| 150 | |
| 151 | tokensBootstrapLog.Printf("Returning %d deduplicated secret requirements", len(allRequirements)) |
| 152 | return allRequirements, nil |
| 153 | } |