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

Function buildCommentAuthorAssociationCondition

pkg/workflow/expression_builder.go:179–209  ·  view source on GitHub ↗

buildCommentAuthorAssociationCondition returns a ConditionNode that passes for non-comment events and for comment events whose author is an OWNER, MEMBER, or COLLABORATOR. Actors listed in bots (from on.bots) are also exempted so that bot/app-triggered workflows continue to work even though bots rar

(bots []string)

Source from the content-addressed store, hash-verified

177// workflows) while remaining transparent to non-comment events such as push or schedule,
178// and preserves existing on.bots allow-list behaviour.
179func buildCommentAuthorAssociationCondition(bots []string) ConditionNode {
180 notIssueComment := BuildNotEquals(
181 BuildPropertyAccess("github.event_name"),
182 BuildStringLiteral("issue_comment"),
183 )
184 notPRReviewComment := BuildNotEquals(
185 BuildPropertyAccess("github.event_name"),
186 BuildStringLiteral("pull_request_review_comment"),
187 )
188 notCommentEvent := BuildAnd(notIssueComment, notPRReviewComment)
189
190 authorizedAssoc := BuildFunctionCall(
191 "contains",
192 BuildFunctionCall("fromJSON", BuildStringLiteral(`["OWNER","MEMBER","COLLABORATOR"]`)),
193 BuildPropertyAccess("github.event.comment.author_association"),
194 )
195
196 result := BuildOr(notCommentEvent, authorizedAssoc)
197 if len(bots) > 0 {
198 botTerms := make([]ConditionNode, len(bots))
199 for i, bot := range bots {
200 botTerms[i] = BuildEquals(
201 BuildPropertyAccess("github.actor"),
202 BuildStringLiteral(bot),
203 )
204 }
205 result = BuildOr(result, BuildDisjunction(false, botTerms...))
206 }
207
208 return result
209}
210
211func buildAuthorAssociationNodeForEvent(eventName string) ConditionNode {
212 switch eventName {

Calls 8

BuildNotEqualsFunction · 0.85
BuildPropertyAccessFunction · 0.85
BuildStringLiteralFunction · 0.85
BuildAndFunction · 0.85
BuildFunctionCallFunction · 0.85
BuildOrFunction · 0.85
BuildEqualsFunction · 0.85
BuildDisjunctionFunction · 0.85

Tested by

no test coverage detected