ExtractWorkflowInputExpressionsFromValue extracts simple workflow input expressions from a string value and maps them to deterministic environment variable names. Returns a map of env var name -> full expression. Examples: - "${{ inputs.target_repo }}" -> {"GH_AW_INPUT_TARGET_REPO": "${{ inputs.tar
(value string)
| 279 | // - "${{ inputs.target_repo }}" -> {"GH_AW_INPUT_TARGET_REPO": "${{ inputs.target_repo }}"} |
| 280 | // - "${{ inputs['base-branch'] }}" -> {"GH_AW_INPUT_BASE_BRANCH": "${{ inputs['base-branch'] }}"} |
| 281 | func ExtractWorkflowInputExpressionsFromValue(value string) map[string]string { |
| 282 | result := make(map[string]string) |
| 283 | |
| 284 | processMatch := func(match []string) { |
| 285 | if len(match) < 2 { |
| 286 | return |
| 287 | } |
| 288 | inputName := match[1] |
| 289 | fullExpr := match[0] |
| 290 | envVar := formatInputNameAsEnvVar(inputName) |
| 291 | result[envVar] = fullExpr |
| 292 | secretLog.Printf("Extracted workflow input expression: %s -> %s", fullExpr, envVar) |
| 293 | } |
| 294 | |
| 295 | for _, match := range workflowInputDotExprPattern.FindAllStringSubmatch(value, -1) { |
| 296 | processMatch(match) |
| 297 | } |
| 298 | |
| 299 | for _, match := range workflowInputBracketExprPattern.FindAllStringSubmatch(value, -1) { |
| 300 | processMatch(match) |
| 301 | } |
| 302 | |
| 303 | return result |
| 304 | } |
| 305 | |
| 306 | func formatInputNameAsEnvVar(inputName string) string { |
| 307 | normalized := strings.Map(func(r rune) rune { |