@@ -10,11 +10,71 @@ module.exports = {
1010 name : options . name ,
1111 requiredConfig : [ 'publicURL' , 'token' , 'userOrOrganization' , 'repo' , 'commitSha' ] ,
1212
13+ willDeploy ( context ) {
14+ return this . notifyPullRequestOfDeployPending ( context ) ;
15+ } ,
16+
1317 didDeploy ( context ) {
14- return this . notifyPullRequestOfDeploy ( context ) ;
18+ return this . notifyPullRequestOfDeploySuccess ( context ) ;
19+ } ,
20+
21+ didFail ( context ) {
22+ return this . notifyPullRequestOfDeployError ( context ) ;
23+ } ,
24+
25+ notifyPullRequestOfDeployError ( context ) {
26+ let github = new GitHubApi ( ) ;
27+
28+ github . authenticate ( {
29+ type : 'oauth' ,
30+ token : this . readConfig ( 'token' ) ,
31+ } ) ;
32+
33+ return new Promise ( ( resolve , reject ) => {
34+ github . repos . createStatus ( {
35+ owner : this . readConfig ( 'userOrOrganization' ) ,
36+ repo : this . readConfig ( 'repo' ) ,
37+ sha : this . readConfig ( 'commitSha' ) ,
38+ state : 'error' ,
39+ description : 'Build failed!' ,
40+ context : 'ember-cli-deploy' ,
41+ } , ( error , result ) => {
42+ if ( error ) {
43+ reject ( error ) ;
44+ } else {
45+ resolve ( result ) ;
46+ }
47+ } ) ;
48+ } ) ;
49+ } ,
50+
51+ notifyPullRequestOfDeployPending ( context ) {
52+ let github = new GitHubApi ( ) ;
53+
54+ github . authenticate ( {
55+ type : 'oauth' ,
56+ token : this . readConfig ( 'token' ) ,
57+ } ) ;
58+
59+ return new Promise ( ( resolve , reject ) => {
60+ github . repos . createStatus ( {
61+ owner : this . readConfig ( 'userOrOrganization' ) ,
62+ repo : this . readConfig ( 'repo' ) ,
63+ sha : this . readConfig ( 'commitSha' ) ,
64+ state : 'pending' ,
65+ description : 'Building application!' ,
66+ context : 'ember-cli-deploy' ,
67+ } , ( error , result ) => {
68+ if ( error ) {
69+ reject ( error ) ;
70+ } else {
71+ resolve ( result ) ;
72+ }
73+ } ) ;
74+ } ) ;
1575 } ,
1676
17- notifyPullRequestOfDeploy ( context ) {
77+ notifyPullRequestOfDeploySuccess ( context ) {
1878 let github = new GitHubApi ( ) ;
1979
2080 github . authenticate ( {
@@ -28,6 +88,7 @@ module.exports = {
2888 repo : this . readConfig ( 'repo' ) ,
2989 sha : this . readConfig ( 'commitSha' ) ,
3090 state : 'success' ,
91+ description : 'Complete build!' ,
3192 target_url : this . readConfig ( 'publicURL' ) ,
3293 context : 'ember-cli-deploy' ,
3394 } , ( error , result ) => {
0 commit comments