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

Function buildSkipAuthorAssociationsCondition

pkg/workflow/expression_builder.go:229–267  ·  view source on GitHub ↗

buildSkipAuthorAssociationsCondition returns a condition that evaluates to true when the workflow should continue, and false when the run should be skipped based on: on.skip-author-associations. containing the event-specific author_association field.

(skipAuthorAssociations map[string][]string)

Source from the content-addressed store, hash-verified

227// workflow should continue, and false when the run should be skipped based on:
228// on.skip-author-associations.<event> containing the event-specific author_association field.
229func buildSkipAuthorAssociationsCondition(skipAuthorAssociations map[string][]string) ConditionNode {
230 var eventNames []string
231 for eventName, associations := range skipAuthorAssociations {
232 if len(associations) > 0 {
233 eventNames = append(eventNames, eventName)
234 }
235 }
236 sort.Strings(eventNames)
237
238 var skipTerms []ConditionNode
239 for _, eventName := range eventNames {
240 associations := skipAuthorAssociations[eventName]
241 if len(associations) == 0 {
242 continue
243 }
244
245 associationJSON, err := json.Marshal(associations)
246 if err != nil {
247 continue
248 }
249
250 isConfiguredEvent := BuildEquals(
251 BuildPropertyAccess("github.event_name"),
252 BuildStringLiteral(eventName),
253 )
254 associationIsSkipped := BuildFunctionCall(
255 "contains",
256 BuildFunctionCall("fromJSON", BuildStringLiteral(string(associationJSON))),
257 buildAuthorAssociationNodeForEvent(eventName),
258 )
259 skipTerms = append(skipTerms, BuildAnd(isConfiguredEvent, associationIsSkipped))
260 }
261
262 if len(skipTerms) == 0 {
263 return BuildBooleanLiteral(true)
264 }
265
266 return &NotNode{Child: BuildDisjunction(false, skipTerms...)}
267}
268
269// buildDetectionSuccessCondition builds the condition to check if detection passed.
270// Detection runs in a separate detection job that only succeeds (result == 'success') when

Calls 8

BuildEqualsFunction · 0.85
BuildPropertyAccessFunction · 0.85
BuildStringLiteralFunction · 0.85
BuildFunctionCallFunction · 0.85
BuildAndFunction · 0.85
BuildBooleanLiteralFunction · 0.85
BuildDisjunctionFunction · 0.85

Tested by

no test coverage detected