parseRepositoryTrigger parses repository lifecycle triggers
(tokens []string)
| 531 | |
| 532 | // parseRepositoryTrigger parses repository lifecycle triggers |
| 533 | func parseRepositoryTrigger(tokens []string) (*TriggerIR, error) { |
| 534 | if len(tokens) < 2 { |
| 535 | return nil, errors.New("repository trigger requires an activity type. Expected format: 'repository <type>'. Valid types: starred, forked. Example: 'repository starred'") |
| 536 | } |
| 537 | |
| 538 | activityType := tokens[1] |
| 539 | |
| 540 | // Map activity types to events |
| 541 | switch activityType { |
| 542 | case "starred": |
| 543 | // GitHub Actions uses "watch" event for starring |
| 544 | return &TriggerIR{ |
| 545 | Event: "watch", |
| 546 | Types: []string{"started"}, |
| 547 | AdditionalEvents: map[string]any{ |
| 548 | "workflow_dispatch": nil, |
| 549 | }, |
| 550 | }, nil |
| 551 | case "forked": |
| 552 | return &TriggerIR{ |
| 553 | Event: "fork", |
| 554 | Filters: map[string]any{}, // Empty map to avoid null in YAML |
| 555 | AdditionalEvents: map[string]any{ |
| 556 | "workflow_dispatch": nil, |
| 557 | }, |
| 558 | }, nil |
| 559 | default: |
| 560 | return nil, fmt.Errorf("invalid repository activity type: '%s'. Valid types: starred, forked. Example: 'repository starred'", activityType) |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | // parseSecurityTrigger parses security-related triggers |
| 565 | func parseSecurityTrigger(input string) (*TriggerIR, error) { |
no test coverage detected