@@ -21,7 +21,7 @@ export async function publishForRunners(
2121
2222 const checkBodySizeResult = checkBodySize ( body , headers ) ;
2323
24- const { event, eventType } = readEvent ( headers , body ) ;
24+ const { event, eventType } = readEvent ( headers , body , [ 'workflow_job' ] ) ;
2525 logger . info ( `Github event ${ event . action } accepted for ${ event . repository . full_name } ` ) ;
2626 if ( checkBodySizeResult . sizeExceeded ) {
2727 // We only warn for large event, when moving the event bridge we can only can accept events up to 256KB
@@ -39,11 +39,10 @@ export async function publishOnEventBridge(
3939
4040 await verifySignature ( headers , body , config . webhookSecret ) ;
4141
42- const eventType = headers [ 'x-github-event' ] as string ;
43- checkEventIsSupported ( eventType , config . allowedEvents ) ;
44-
4542 const checkBodySizeResult = checkBodySize ( body , headers ) ;
4643
44+ const { eventType } = readEvent ( headers , body , config . allowedEvents ) ;
45+
4746 logger . info (
4847 `Github event ${ headers [ 'x-github-event' ] as string } accepted for ` +
4948 `${ headers [ 'x-github-hook-installation-target-id' ] as string } ` ,
@@ -127,9 +126,13 @@ function checkEventIsSupported(eventType: string, allowedEvents: string[]): void
127126 }
128127}
129128
130- function readEvent ( headers : IncomingHttpHeaders , body : string ) : { event : WorkflowJobEvent ; eventType : string } {
129+ function readEvent (
130+ headers : IncomingHttpHeaders ,
131+ body : string ,
132+ allowedEvents : string [ ] ,
133+ ) : { event : WorkflowJobEvent ; eventType : string } {
131134 const eventType = headers [ 'x-github-event' ] as string ;
132- checkEventIsSupported ( eventType , [ 'workflow_job' ] ) ;
135+ checkEventIsSupported ( eventType , allowedEvents ) ;
133136
134137 const event = JSON . parse ( body ) as WorkflowJobEvent ;
135138 logger . appendPersistentKeys ( {
0 commit comments