1- const { PR_NUMBER , PR_TITLE } = require ( "./constants" )
1+ const { PR_NUMBER , PR_TITLE , AREAS } = require ( "./constants" )
22
33module . exports = async ( { github, context, core} ) => {
44 const FEAT_REGEX = / f e a t ( \( ( .+ ) \) ) ? ( \: .+ ) /
@@ -26,12 +26,27 @@ module.exports = async ({github, context, core}) => {
2626 if ( isMatch != null ) {
2727 core . info ( `Auto-labeling PR ${ PR_NUMBER } with ${ label } ` )
2828
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 ]
3434 } )
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 ;
3550 } else {
3651 core . debug ( `'${ PR_TITLE } ' didn't match '${ label } ' semantic.` )
3752 miss += 1
@@ -42,4 +57,4 @@ module.exports = async ({github, context, core}) => {
4257 return core . notice ( `PR ${ PR_NUMBER } title '${ PR_TITLE } ' doesn't follow semantic titles; skipping...` )
4358 }
4459 }
45- }
60+ }
0 commit comments