MCPcopy Create free account
hub / github.com/github/gh-aw / buildLabelNamesCondition

Function buildLabelNamesCondition

pkg/workflow/compiler_pre_activation_job.go:469–486  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

467// clearer and handles cases where GitHub Actions evaluates missing nested properties
468// as null before coercing to empty string.
469func 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

Calls 7

ConditionNodeInterface · 0.85
BuildEqualsFunction · 0.85
BuildPropertyAccessFunction · 0.85
BuildNullLiteralFunction · 0.85
BuildOrFunction · 0.85
BuildStringLiteralFunction · 0.85
RenderMethod · 0.65

Tested by 1