@@ -19,24 +19,30 @@ module.exports = async ({github, context, core}) => {
19
19
20
20
21
21
const RELATED_ISSUE_REGEX = / I s s u e n u m b e r : [ ^ \d \r \n ] + (?< issue > \d + ) / ;
22
- const isMatch = RELATED_ISSUE_REGEX . exec ( PR_BODY ) ;
23
- if ( ! isMatch ) {
24
- core . setFailed ( `Unable to find related issue for PR number ${ PR_NUMBER } .\n\n Body details: ${ PR_BODY } ` ) ;
25
- return await github . rest . issues . createComment ( {
22
+
23
+ try {
24
+ const isMatch = RELATED_ISSUE_REGEX . exec ( PR_BODY ) ;
25
+ if ( ! isMatch ) {
26
+ core . setFailed ( `Unable to find related issue for PR number ${ PR_NUMBER } .\n\n Body details: ${ PR_BODY } ` ) ;
27
+ return await github . rest . issues . createComment ( {
28
+ owner : context . repo . owner ,
29
+ repo : context . repo . repo ,
30
+ body : `${ HANDLE_MAINTAINERS_TEAM } No related issues found. Please ensure '${ LABEL_PENDING_RELEASE } ' label is applied before releasing.` ,
31
+ issue_number : PR_NUMBER ,
32
+ } ) ;
33
+ }
34
+
35
+ const { groups : { issue} } = isMatch
36
+
37
+ core . info ( `Auto-labeling related issue ${ issue } for release` )
38
+ return await github . rest . issues . addLabels ( {
39
+ issue_number : issue ,
26
40
owner : context . repo . owner ,
27
41
repo : context . repo . repo ,
28
- body : `${ HANDLE_MAINTAINERS_TEAM } No related issues found. Please ensure '${ LABEL_PENDING_RELEASE } ' label is applied before releasing.` ,
29
- issue_number : PR_NUMBER ,
30
- } ) ;
42
+ labels : [ LABEL_PENDING_RELEASE ]
43
+ } )
44
+ } catch ( error ) {
45
+ core . setFailed ( `Is this issue number (${ issue } ) valid? Perhaps a discussion?` ) ;
46
+ throw new Error ( error ) ;
31
47
}
32
-
33
- const { groups : { issue} } = isMatch
34
-
35
- core . info ( `Auto-labeling related issue ${ issue } for release` )
36
- return await github . rest . issues . addLabels ( {
37
- issue_number : issue ,
38
- owner : context . repo . owner ,
39
- repo : context . repo . repo ,
40
- labels : [ LABEL_PENDING_RELEASE ]
41
- } )
42
48
}
0 commit comments