buildLabelNamesCondition constructs the GitHub Actions if: expression for labels filtering. The generated condition passes when: - the event has no label object (github.event.label == null), which covers workflow_dispatch, push, schedule, and any other non-labeled events, OR - the triggering label n
(labelNames []string)
| 467 | // clearer and handles cases where GitHub Actions evaluates missing nested properties |
| 468 | // as null before coercing to empty string. |
| 469 | func buildLabelNamesCondition(labelNames []string) string { |
| 470 | // Pass through events without a label payload. |
| 471 | // github.event.label is null for workflow_dispatch, push, schedule, etc. |
| 472 | noLabelEvent := ConditionNode(BuildEquals( |
| 473 | BuildPropertyAccess("github.event.label"), |
| 474 | BuildNullLiteral(), |
| 475 | )) |
| 476 | |
| 477 | result := noLabelEvent |
| 478 | for _, name := range labelNames { |
| 479 | result = BuildOr(result, BuildEquals( |
| 480 | BuildPropertyAccess("github.event.label.name"), |
| 481 | BuildStringLiteral(name), |
| 482 | )) |
| 483 | } |
| 484 | |
| 485 | return result.Render() |
| 486 | } |
| 487 | |
| 488 | // hasCommentEventInOn reports whether the rendered on: section includes issue_comment or |
| 489 | // pull_request_review_comment events. These are the events flagged by RGS-004 because |