1
- const { PR_NUMBER , PR_TITLE } = require ( "./constants" )
1
+ const { PR_NUMBER , PR_TITLE , AREAS } = require ( "./constants" )
2
2
3
3
module . exports = async ( { github, context, core} ) => {
4
4
const FEAT_REGEX = / f e a t ( \( ( .+ ) \) ) ? ( \: .+ ) /
@@ -26,12 +26,27 @@ module.exports = async ({github, context, core}) => {
26
26
if ( isMatch != null ) {
27
27
core . info ( `Auto-labeling PR ${ PR_NUMBER } with ${ label } ` )
28
28
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 ]
29
+ await github . rest . issues . addLabels ( {
30
+ issue_number : PR_NUMBER ,
31
+ owner : context . repo . owner ,
32
+ repo : context . repo . repo ,
33
+ labels : [ label ]
34
34
} )
35
+
36
+ const area = matches [ 2 ] ; // second capture group contains the area
37
+ if ( AREAS . indexOf ( area ) > - 1 ) {
38
+ core . info ( `Auto-labeling PR ${ PR_NUMBER } with area ${ area } ` ) ;
39
+ await github . rest . issues . addLabels ( {
40
+ issue_number : PR_NUMBER ,
41
+ owner : context . repo . owner ,
42
+ repo : context . repo . repo ,
43
+ labels : [ `area/${ area } ` ] ,
44
+ } ) ;
45
+ } else {
46
+ core . debug ( `'${ PR_TITLE } ' didn't match any known area.` ) ;
47
+ }
48
+
49
+ return ;
35
50
} else {
36
51
core . debug ( `'${ PR_TITLE } ' didn't match '${ label } ' semantic.` )
37
52
miss += 1
@@ -42,4 +57,4 @@ module.exports = async ({github, context, core}) => {
42
57
return core . notice ( `PR ${ PR_NUMBER } title '${ PR_TITLE } ' doesn't follow semantic titles; skipping...` )
43
58
}
44
59
}
45
- }
60
+ }
0 commit comments