@@ -30,39 +30,39 @@ async function handleWorkflowJob(
30
30
githubEvent : string ,
31
31
matcherConfig : Array < RunnerMatcherConfig > ,
32
32
) : Promise < Response > {
33
- if ( body . action === 'queued' ) {
34
- // sort the queuesConfig by order of matcher config exact match, with all true matches lined up ahead.
35
- matcherConfig . sort ( ( a , b ) => {
36
- return a . matcherConfig . exactMatch === b . matcherConfig . exactMatch ? 0 : a . matcherConfig . exactMatch ? - 1 : 1 ;
37
- } ) ;
38
- for ( const queue of matcherConfig ) {
39
- if ( canRunJob ( body . workflow_job . labels , queue . matcherConfig . labelMatchers , queue . matcherConfig . exactMatch ) ) {
40
- await sendActionRequest ( {
41
- id : body . workflow_job . id ,
42
- repositoryName : body . repository . name ,
43
- repositoryOwner : body . repository . owner . login ,
44
- eventType : githubEvent ,
45
- installationId : body . installation ?. id ?? 0 ,
46
- queueId : queue . id ,
47
- repoOwnerType : body . repository . owner . type ,
48
- } ) ;
49
- logger . info ( `Successfully dispatched job for ${ body . repository . full_name } to the queue ${ queue . id } ` ) ;
50
- return {
51
- statusCode : 201 ,
52
- body : `Successfully queued job for ${ body . repository . full_name } to the queue ${ queue . id } ` ,
53
- } ;
54
- }
55
- }
56
- logger . warn ( `Received event contains runner labels '${ body . workflow_job . labels } ' that are not accepted.` ) ;
33
+ if ( body . action !== 'queued' ) {
57
34
return {
58
- statusCode : 202 ,
59
- body : `Received event contains runner labels ' ${ body . workflow_job . labels } ' that are not accepted .` ,
35
+ statusCode : 201 ,
36
+ body : `Workflow job not queued, not dispatching to queue .` ,
60
37
} ;
61
38
}
62
- return {
63
- statusCode : 201 ,
64
- body : `Received not queued and will not be ignored.` ,
65
- } ;
39
+ // sort the queuesConfig by order of matcher config exact match, with all true matches lined up ahead.
40
+ matcherConfig . sort ( ( a , b ) => {
41
+ return a . matcherConfig . exactMatch === b . matcherConfig . exactMatch ? 0 : a . matcherConfig . exactMatch ? - 1 : 1 ;
42
+ } ) ;
43
+ for ( const queue of matcherConfig ) {
44
+ if ( canRunJob ( body . workflow_job . labels , queue . matcherConfig . labelMatchers , queue . matcherConfig . exactMatch ) ) {
45
+ await sendActionRequest ( {
46
+ id : body . workflow_job . id ,
47
+ repositoryName : body . repository . name ,
48
+ repositoryOwner : body . repository . owner . login ,
49
+ eventType : githubEvent ,
50
+ installationId : body . installation ?. id ?? 0 ,
51
+ queueId : queue . id ,
52
+ repoOwnerType : body . repository . owner . type ,
53
+ } ) ;
54
+ logger . info ( `Successfully dispatched job for ${ body . repository . full_name } to the queue ${ queue . id } ` ) ;
55
+ return {
56
+ statusCode : 201 ,
57
+ body : `Successfully queued job for ${ body . repository . full_name } to the queue ${ queue . id } ` ,
58
+ } ;
59
+ }
60
+ }
61
+ const notAcceptedErrorMsg = `Received event contains runner labels '${ body . workflow_job . labels } ' from '${
62
+ body . repository . full_name
63
+ } ' that are not accepted.`;
64
+ logger . warn ( notAcceptedErrorMsg ) ;
65
+ return { statusCode : 202 , body : notAcceptedErrorMsg } ;
66
66
}
67
67
68
68
export function canRunJob (
0 commit comments