@@ -243,6 +243,10 @@ func detectMatched(gitRepo *git.Repository, commit *git.Commit, triggedEvent web
243243 webhook_module .HookEventPackage :
244244 return matchPackageEvent (payload .(* api.PackagePayload ), evt )
245245
246+ case // registry_package
247+ webhook_module .HookEventWorkflowRun :
248+ return matchWorkflowRunEvent (payload .(* api.WorkflowRunPayload ), evt )
249+
246250 default :
247251 log .Warn ("unsupported event %q" , triggedEvent )
248252 return false
@@ -698,3 +702,45 @@ func matchPackageEvent(payload *api.PackagePayload, evt *jobparser.Event) bool {
698702 }
699703 return matchTimes == len (evt .Acts ())
700704}
705+
706+ func matchWorkflowRunEvent (payload * api.WorkflowRunPayload , evt * jobparser.Event ) bool {
707+ // with no special filter parameters
708+ if len (evt .Acts ()) == 0 {
709+ return true
710+ }
711+
712+ matchTimes := 0
713+ // all acts conditions should be satisfied
714+ for cond , vals := range evt .Acts () {
715+ switch cond {
716+ case "types" :
717+ action := payload .Action
718+ for _ , val := range vals {
719+ if glob .MustCompile (val , '/' ).Match (string (action )) {
720+ matchTimes ++
721+ break
722+ }
723+ }
724+ case "workflows" :
725+ workflow := payload .Workflow
726+ patterns , err := workflowpattern .CompilePatterns (vals ... )
727+ if err != nil {
728+ break
729+ }
730+ if ! workflowpattern .Skip (patterns , []string {workflow .Name }, & workflowpattern.EmptyTraceWriter {}) {
731+ matchTimes ++
732+ }
733+ case "branches" :
734+ patterns , err := workflowpattern .CompilePatterns (vals ... )
735+ if err != nil {
736+ break
737+ }
738+ if ! workflowpattern .Skip (patterns , []string {payload .WorkflowRun .HeadBranch }, & workflowpattern.EmptyTraceWriter {}) {
739+ matchTimes ++
740+ }
741+ default :
742+ log .Warn ("package event unsupported condition %q" , cond )
743+ }
744+ }
745+ return matchTimes == len (evt .Acts ())
746+ }
0 commit comments