extractConcurrencySection extracts the workflow-level concurrency YAML section, stripping the gh-aw-specific job-discriminator field so it does not appear in the compiled lock file (which must be valid GitHub Actions YAML).
(frontmatter map[string]any)
| 511 | // stripping the gh-aw-specific job-discriminator field so it does not appear in |
| 512 | // the compiled lock file (which must be valid GitHub Actions YAML). |
| 513 | func (c *Compiler) extractConcurrencySection(frontmatter map[string]any) string { |
| 514 | concurrencyRaw, ok := frontmatter["concurrency"] |
| 515 | if !ok { |
| 516 | return "" |
| 517 | } |
| 518 | concurrencyMap, ok := concurrencyRaw.(map[string]any) |
| 519 | if !ok || len(concurrencyMap) == 0 { |
| 520 | // String or empty format: serialize as-is (no job-discriminator possible) |
| 521 | return c.extractTopLevelYAMLSection(frontmatter, "concurrency") |
| 522 | } |
| 523 | |
| 524 | _, hasDiscriminator := concurrencyMap["job-discriminator"] |
| 525 | if !hasDiscriminator { |
| 526 | return c.extractTopLevelYAMLSection(frontmatter, "concurrency") |
| 527 | } |
| 528 | |
| 529 | // Build a copy of the concurrency map without job-discriminator for serialization. |
| 530 | // Use len(concurrencyMap) for capacity: at most one entry (job-discriminator) will be |
| 531 | // omitted, so this is a slight over-allocation that avoids a subtle negative-capacity |
| 532 | // edge case if job-discriminator were the only key. |
| 533 | cleanMap := make(map[string]any, len(concurrencyMap)) |
| 534 | for k, v := range concurrencyMap { |
| 535 | if k != "job-discriminator" { |
| 536 | cleanMap[k] = v |
| 537 | } |
| 538 | } |
| 539 | // When job-discriminator is the only field, there is no user-specified workflow-level |
| 540 | // group to emit; return empty so the compiler can generate the default concurrency. |
| 541 | if len(cleanMap) == 0 { |
| 542 | return "" |
| 543 | } |
| 544 | // Use a minimal temporary frontmatter containing only the concurrency key to avoid |
| 545 | // copying the entire (potentially large) frontmatter map. |
| 546 | return c.extractTopLevelYAMLSection(map[string]any{"concurrency": cleanMap}, "concurrency") |
| 547 | } |
| 548 | |
| 549 | // extractDispatchItemNumber reports whether the frontmatter's on.workflow_dispatch |
| 550 | // trigger exposes an item_number input. This is the signature produced by the label |