@@ -21,19 +21,39 @@ module.exports = function postDeploy() {
21
21

22
22
` ;
23
23
24
- request . post (
24
+ request . get (
25
25
{
26
26
url : issueUrl ,
27
- headers : { 'User-Agent' : 'ci' } ,
28
- body : JSON . stringify ( { body } )
27
+ headers : { 'User-Agent' : 'ci' }
29
28
} ,
30
- ( error , response ) => {
31
- if ( error ) {
32
- console . error ( 'Failed to post comment to GitHub, an error occurred' , error ) ;
33
- } else if ( response . statusCode >= 400 ) {
34
- console . error ( 'Failed to post comment to GitHub, request failed with' , response ) ;
29
+ ( getError , getResponse ) => {
30
+ if ( getError ) {
31
+ console . error ( 'Failed to check comments on GitHub, an error occurred' , getError ) ;
32
+ } else if ( getResponse . statusCode >= 400 ) {
33
+ console . error ( 'Failed to check comments on GitHub, request failed with' , getResponse ) ;
35
34
} else {
36
- console . log ( `Posted message to GitHub PR #${ config . githubPullRequestId } ` ) ;
35
+ const comments = JSON . parse ( getResponse . body ) ;
36
+ if ( ! comments . filter ( comment => comment . body === body ) . length ) {
37
+ request . post (
38
+ {
39
+ url : issueUrl ,
40
+ headers : { 'User-Agent' : 'ci' } ,
41
+ body : JSON . stringify ( { body } )
42
+ } ,
43
+ ( postError , postResponse ) => {
44
+ if ( postError ) {
45
+ console . error ( 'Failed to post comment to GitHub, an error occurred' , postError ) ;
46
+ } else if ( postResponse . statusCode >= 400 ) {
47
+ console . error (
48
+ 'Failed to post comment to GitHub, request failed with' ,
49
+ postResponse
50
+ ) ;
51
+ } else {
52
+ console . log ( `Posted message to GitHub PR #${ config . githubPullRequestId } ` ) ;
53
+ }
54
+ }
55
+ ) ;
56
+ }
37
57
}
38
58
}
39
59
) ;
0 commit comments