@@ -18,22 +18,28 @@ module.exports = async ({github, context, core}) => {
18
18
}
19
19
20
20
// Maintenance: We should keep track of modified PRs in case their titles change
21
- for ( const label in labels ) {
22
- const matcher = new RegExp ( labels [ label ] )
23
- const isMatch = matcher . exec ( PR_TITLE )
24
- if ( isMatch != null ) {
25
- core . info ( `Auto-labeling PR ${ PR_NUMBER } with ${ label } ` )
21
+ let miss = 0 ;
22
+ try {
23
+ for ( const label in labels ) {
24
+ const matcher = new RegExp ( labels [ label ] )
25
+ const isMatch = matcher . exec ( PR_TITLE )
26
+ if ( isMatch != null ) {
27
+ core . info ( `Auto-labeling PR ${ PR_NUMBER } with ${ label } ` )
26
28
27
- await github . rest . issues . addLabels ( {
28
- issue_number : PR_NUMBER ,
29
- owner : context . repo . owner ,
30
- repo : context . repo . repo ,
31
- labels : [ label ]
32
- } )
33
-
34
- break
29
+ return await github . rest . issues . addLabels ( {
30
+ issue_number : PR_NUMBER ,
31
+ owner : context . repo . owner ,
32
+ repo : context . repo . repo ,
33
+ labels : [ label ]
34
+ } )
35
+ } else {
36
+ core . debug ( `'${ PR_TITLE } ' didn't match '${ label } ' semantic.` )
37
+ miss += 1
38
+ }
39
+ }
40
+ } finally {
41
+ if ( miss == Object . keys ( labels ) . length ) {
42
+ return core . notice ( `PR ${ PR_NUMBER } title '${ PR_TITLE } ' doesn't follow semantic titles; skipping...` )
35
43
}
36
44
}
37
-
38
- return core . notice ( `PR ${ PR_NUMBER } title '${ PR_TITLE } ' doesn't follow semantic titles; skipping...` )
39
45
}
0 commit comments