extractOutputs extracts output parameters from core.setOutput() calls
(content string)
| 254 | |
| 255 | // extractOutputs extracts output parameters from core.setOutput() calls |
| 256 | func extractOutputs(content string) []ActionOutput { |
| 257 | var outputs []ActionOutput |
| 258 | seen := make(map[string]struct { |
| 259 | }) |
| 260 | |
| 261 | // Match core.setOutput('name', ...) or core.setOutput("name", ...) |
| 262 | matches := coreSetOutputPattern.FindAllStringSubmatch(content, -1) |
| 263 | |
| 264 | for _, match := range matches { |
| 265 | if len(match) > 1 { |
| 266 | outputName := match[1] |
| 267 | if !setutil.Contains(seen, outputName) { |
| 268 | outputs = append(outputs, ActionOutput{ |
| 269 | Name: outputName, |
| 270 | Description: "Output parameter: " + outputName, |
| 271 | }) |
| 272 | seen[outputName] = struct { |
| 273 | }{} |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | // Sort outputs by name for consistency |
| 279 | slices.SortFunc(outputs, func(a, b ActionOutput) int { |
| 280 | switch { |
| 281 | case a.Name < b.Name: |
| 282 | return -1 |
| 283 | case a.Name > b.Name: |
| 284 | return 1 |
| 285 | default: |
| 286 | return 0 |
| 287 | } |
| 288 | }) |
| 289 | |
| 290 | return outputs |
| 291 | } |
| 292 | |
| 293 | // extractDependencies extracts require() dependencies |
| 294 | func extractDependencies(content string) []string { |