@@ -7,127 +7,139 @@ function PullRequest (githubToken) {
77 this . github = new Github ( { token : githubToken } ) ;
88}
99
10- PullRequest . prototype . buildStarted = function ( repo , commit , targetUrl , cb ) {
10+ PullRequest . prototype . buildStarted = function ( pullRequestInfo , targetUrl , cb ) {
1111 debug ( 'buildStarted' , formatArgs ( arguments ) ) ;
1212 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
1313 return cb ( null ) ;
1414 }
1515 var payload = {
1616 state : 'pending' ,
17- description : 'A build has been started .' ,
17+ description : 'PR-' + pullRequestInfo . number + ' is building on Runnable .',
1818 // we use url to differentiate between several runnable builds
1919 context : targetUrl ,
2020 target_url : targetUrl ,
21- sha : commit
21+ sha : pullRequestInfo . commit
2222 } ;
23- this . github . createBuildStatus ( repo , payload , cb ) ;
23+ this . github . createBuildStatus ( pullRequestInfo . repo , payload , cb ) ;
2424} ;
2525
26- PullRequest . prototype . buildSucceeded = function ( repo , commit , targetUrl , cb ) {
26+ PullRequest . prototype . buildSucceeded = function ( pullRequestInfo , targetUrl , cb ) {
2727 debug ( 'buildSucceeded' , formatArgs ( arguments ) ) ;
2828 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
2929 return cb ( null ) ;
3030 }
3131 var payload = {
3232 state : 'success' ,
33- description : 'A build has been completed .' ,
33+ description : 'PR-' + pullRequestInfo . number + ' is ready to run on Runnable .',
3434 // we use url to differentiate between several runnable builds
3535 context : targetUrl ,
3636 target_url : targetUrl ,
37- sha : commit
37+ sha : pullRequestInfo . commit
3838 } ;
39- this . github . createBuildStatus ( repo , payload , cb ) ;
39+ this . github . createBuildStatus ( pullRequestInfo . repo , payload , cb ) ;
4040} ;
4141
42- PullRequest . prototype . buildErrored = function ( repo , commit , targetUrl , cb ) {
42+ PullRequest . prototype . buildErrored = function ( pullRequestInfo , targetUrl , cb ) {
4343 debug ( 'buildErrored' , formatArgs ( arguments ) ) ;
4444 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
4545 return cb ( null ) ;
4646 }
4747 var payload = {
4848 state : 'error' ,
49- description : 'A build has been completed with an error.' ,
49+ description : 'Select a server to build PR-' + pullRequestInfo . number ,
5050 // we use url to differentiate between several runnable builds
5151 context : targetUrl ,
52- target_url : targetUrl
52+ target_url : targetUrl ,
53+ sha : pullRequestInfo . commit
5354 } ;
54- this . github . createBuildStatus ( repo , commit , payload , cb ) ;
55+ this . github . createBuildStatus ( pullRequestInfo . repo , payload , cb ) ;
5556} ;
5657
57- PullRequest . prototype . serverSelectionStatus = function ( repo , commit , targetUrl , cb ) {
58+ PullRequest . prototype . serverSelectionStatus = function ( pullRequestInfo , targetUrl , cb ) {
5859 debug ( 'buildStarted' , formatArgs ( arguments ) ) ;
5960 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
6061 return cb ( null ) ;
6162 }
6263 var payload = {
6364 state : 'pending' ,
64- description : 'Select a server to run this Pull Request ' ,
65+ description : 'PR-' + pullRequestInfo . number + ' is ready to run on Runnable. ',
6566 // we use url to differentiate between several runnable builds
6667 context : targetUrl ,
6768 target_url : targetUrl ,
68- sha : commit
69+ sha : pullRequestInfo . commit
6970 } ;
70- this . github . createBuildStatus ( repo , payload , cb ) ;
71+ this . github . createBuildStatus ( pullRequestInfo . repo , payload , cb ) ;
7172} ;
7273
7374
74- PullRequest . prototype . createDeployment = function ( repo , commit , payload , cb ) {
75+ PullRequest . prototype . createDeployment = function ( pullRequestInfo , serverName , payload , cb ) {
7576 debug ( 'createDeployment' , formatArgs ( arguments ) ) ;
7677 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
7778 return cb ( null ) ;
7879 }
80+ var description = 'Deploying PR-' + pullRequestInfo . number + ' to ' +
81+ serverName + ' on Runnable.' ;
7982 var query = {
8083 auto_merge : false ,
8184 environment : 'runnable' ,
82- description : 'Deploying code to the runnable sandbox.' ,
83- ref : commit ,
85+ description : description ,
86+ ref : pullRequestInfo . commit ,
8487 payload : JSON . stringify ( payload || { } ) ,
8588 required_contexts : [ ] // we skip check on all `contexts` since we still can deploy
8689 } ;
87- this . github . createDeployment ( repo , query , cb ) ;
90+ this . github . createDeployment ( pullRequestInfo . repo , query , cb ) ;
8891} ;
8992
9093
91- PullRequest . prototype . deploymentStarted = function ( repo , deploymentId , targetUrl , cb ) {
94+ PullRequest . prototype . deploymentStarted =
95+ function ( pullRequestInfo , deploymentId , serverName , targetUrl , cb ) {
9296 debug ( 'deploymentStarted' , formatArgs ( arguments ) ) ;
9397 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
9498 return cb ( null ) ;
9599 }
100+ var description = 'Deploying PR-' + pullRequestInfo . number + ' to ' +
101+ serverName + ' on Runnable.' ;
96102 var payload = {
97103 id : deploymentId ,
98104 state : 'pending' ,
99105 target_url : targetUrl ,
100- description : 'Deployment has been started.'
106+ description : description
101107 } ;
102- this . github . createDeploymentStatus ( repo , payload , cb ) ;
108+ this . github . createDeploymentStatus ( pullRequestInfo . repo , payload , cb ) ;
103109} ;
104110
105- PullRequest . prototype . deploymentSucceeded = function ( repo , deploymentId , targetUrl , cb ) {
111+ PullRequest . prototype . deploymentSucceeded =
112+ function ( pullRequestInfo , deploymentId , serverName , targetUrl , cb ) {
106113 debug ( 'deploymentSucceeded' , formatArgs ( arguments ) ) ;
107114 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
108115 return cb ( null ) ;
109116 }
117+ var description = 'Deployed PR-' + pullRequestInfo . number +
118+ ' to ' + serverName + ' on Runnable.' ;
110119 var payload = {
111120 id : deploymentId ,
112121 state : 'success' ,
113122 target_url : targetUrl ,
114- description : 'Deployment has been completed.'
123+ description : description
115124 } ;
116- this . github . createDeploymentStatus ( repo , payload , cb ) ;
125+ this . github . createDeploymentStatus ( pullRequestInfo . repo , payload , cb ) ;
117126} ;
118127
119- PullRequest . prototype . deploymentErrored = function ( repo , deploymentId , targetUrl , cb ) {
128+ PullRequest . prototype . deploymentErrored =
129+ function ( pullRequestInfo , deploymentId , serverName , targetUrl , cb ) {
120130 debug ( 'deploymentErrored' , formatArgs ( arguments ) ) ;
121131 if ( process . env . ENABLE_GITHUB_PR_STATUSES !== 'true' ) {
122132 return cb ( null ) ;
123133 }
134+ var description = 'Failed to deploy PR-' + pullRequestInfo . number +
135+ ' to ' + serverName + ' on Runnable.' ;
124136 var payload = {
125137 id : deploymentId ,
126138 state : 'error' ,
127139 target_url : targetUrl ,
128- description : 'Deployment has been completed with an error.'
140+ description : description
129141 } ;
130- this . github . createDeploymentStatus ( repo , payload , cb ) ;
142+ this . github . createDeploymentStatus ( pullRequestInfo . repo , payload , cb ) ;
131143} ;
132144
133145module . exports = PullRequest ;
0 commit comments