1
+ const {
2
+ PR_AUTHOR ,
3
+ PR_BODY ,
4
+ PR_NUMBER ,
5
+ IGNORE_AUTHORS ,
6
+ LABEL_PENDING_RELEASE ,
7
+ HANDLE_MAINTAINERS_TEAM ,
8
+ PR_IS_MERGED ,
9
+ } = require ( "./constants" )
10
+
1
11
module . exports = async ( { github, context, core} ) => {
2
- const prBody = process . env . PR_BODY ;
3
- const prNumber = process . env . PR_NUMBER ;
4
- const releaseLabel = process . env . RELEASE_LABEL ;
5
- const maintainersTeam = process . env . MAINTAINERS_TEAM ;
6
- const RELATED_ISSUE_REGEX = / I s s u e n u m b e r : [ ^ \d \r \n ] + (?< issue > \d + ) / ;
12
+ core . debug ( PR_BODY ) ;
13
+ core . debug ( PR_IS_MERGED ) ;
14
+
15
+ if ( IGNORE_AUTHORS . includes ( PR_AUTHOR ) ) {
16
+ return core . notice ( "Author in IGNORE_AUTHORS list; skipping..." )
17
+ }
7
18
8
- core . info ( prBody ) ;
9
- const isMatch = RELATED_ISSUE_REGEX . exec ( prBody ) ;
19
+ if ( ! PR_IS_MERGED ) {
20
+ return core . notice ( "Only merged PRs to avoid spam; skipping" )
21
+ }
22
+
23
+
24
+ const RELATED_ISSUE_REGEX = / I s s u e n u m b e r : [ ^ \d \r \n ] + (?< issue > \d + ) / ;
25
+ const isMatch = RELATED_ISSUE_REGEX . exec ( PR_BODY ) ;
10
26
if ( ! isMatch ) {
11
- core . setFailed ( `Unable to find related issue for PR number ${ prNumber } .\n\n Body details: ${ prBody } ` ) ;
27
+ core . setFailed ( `Unable to find related issue for PR number ${ PR_NUMBER } .\n\n Body details: ${ PR_BODY } ` ) ;
12
28
return await github . rest . issues . createComment ( {
13
29
owner : context . repo . owner ,
14
30
repo : context . repo . repo ,
15
- body : `${ maintainersTeam } No related issues found. Please ensure '${ releaseLabel } ' label is applied before releasing.` ,
16
- issue_number : prNumber ,
31
+ body : `${ HANDLE_MAINTAINERS_TEAM } No related issues found. Please ensure '${ LABEL_PENDING_RELEASE } ' label is applied before releasing.` ,
32
+ issue_number : PR_NUMBER ,
17
33
} ) ;
18
34
}
19
35
@@ -24,6 +40,6 @@ module.exports = async ({github, context, core}) => {
24
40
issue_number : relatedIssueNumber ,
25
41
owner : context . repo . owner ,
26
42
repo : context . repo . repo ,
27
- labels : [ releaseLabel ]
43
+ labels : [ LABEL_PENDING_RELEASE ]
28
44
} )
29
45
}
0 commit comments