@@ -10,11 +10,71 @@ module.exports = {
10
10
name : options . name ,
11
11
requiredConfig : [ 'publicURL' , 'token' , 'userOrOrganization' , 'repo' , 'commitSha' ] ,
12
12
13
+ willDeploy ( context ) {
14
+ return this . notifyPullRequestOfDeployPending ( context ) ;
15
+ } ,
16
+
13
17
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
+ } ) ;
15
75
} ,
16
76
17
- notifyPullRequestOfDeploy ( context ) {
77
+ notifyPullRequestOfDeploySuccess ( context ) {
18
78
let github = new GitHubApi ( ) ;
19
79
20
80
github . authenticate ( {
@@ -28,6 +88,7 @@ module.exports = {
28
88
repo : this . readConfig ( 'repo' ) ,
29
89
sha : this . readConfig ( 'commitSha' ) ,
30
90
state : 'success' ,
91
+ description : 'Complete build!' ,
31
92
target_url : this . readConfig ( 'publicURL' ) ,
32
93
context : 'ember-cli-deploy' ,
33
94
} , ( error , result ) => {
0 commit comments