@@ -227,17 +227,46 @@ class GhSHACheckout extends SHACheckoutStep instanceof Run {
227227}
228228
229229/** An If node that contains an actor, user or label check */
230- class ControlCheck extends If {
231- ControlCheck ( ) {
230+ abstract class ControlCheck extends If { }
231+
232+ class LabelControlCheck extends ControlCheck {
233+ LabelControlCheck ( ) {
234+ // eg: contains(github.event.pull_request.labels.*.name, 'safe to test')
235+ // eg: github.event.label.name == 'safe to test'
236+ exists (
237+ Utils:: normalizeExpr ( this .getCondition ( ) )
238+ .regexpFind ( [
239+ "\\bgithub\\.event\\.pull_request\\.labels\\b" , "\\bgithub\\.event\\.label\\.name\\b"
240+ ] , _, _)
241+ )
242+ }
243+ }
244+
245+ class ActorControlCheck extends ControlCheck {
246+ ActorControlCheck ( ) {
247+ // eg: contains(github.actor, 'dependabot')
248+ // eg: github.triggering_actor != 'CI Agent'
249+ // eg: github.event.pull_request.user.login == 'mybot'
250+ exists (
251+ Utils:: normalizeExpr ( this .getCondition ( ) )
252+ .regexpFind ( [
253+ "\\bgithub\\.actor\\b" , "\\bgithub\\.triggering_actor\\b" ,
254+ "\\bgithub\\.event\\.comment\\.user\\.login\\b" ,
255+ "\\bgithub\\.event\\.pull_request\\.user\\.login\\b" ,
256+ ] , _, _)
257+ )
258+ }
259+ }
260+
261+ class AssociationControlCheck extends ControlCheck {
262+ AssociationControlCheck ( ) {
263+ // eg: contains(fromJson('["MEMBER", "OWNER"]'), github.event.comment.author_association)
232264 exists (
233265 Utils:: normalizeExpr ( this .getCondition ( ) )
234266 .regexpFind ( [
235- "\\bgithub\\.actor\\b" , // actor
236- "\\bgithub\\.triggering_actor\\b" , // actor
237- "\\bgithub\\.event\\.comment\\.user\\.login\\b" , //user
238- "\\bgithub\\.event\\.pull_request\\.user\\.login\\b" , //user
239- "\\bgithub\\.event\\.pull_request\\.labels\\b" , // label
240- "\\bgithub\\.event\\.label\\.name\\b" // label
267+ "\\bgithub\\.event\\.comment\\.author_association\\b" ,
268+ "\\bgithub\\.event\\.issue\\.author_association\\b" ,
269+ "\\bgithub\\.event\\.pull_request\\.author_association\\b" ,
241270 ] , _, _)
242271 )
243272 }
0 commit comments