Skip to content

Commit d33511e

Browse files
added hook willDeploy and didfail
1 parent 48a0008 commit d33511e

File tree

2 files changed

+64
-3
lines changed

2 files changed

+64
-3
lines changed

index.js

+63-2
Original file line numberDiff line numberDiff line change
@@ -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) => {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ember-cli-deploy-github-deployments",
3-
"version": "0.1.0",
3+
"version": "0.1.1",
44
"description": "",
55
"scripts": {},
66
"repository": "https://github.com/aureliosaraiva/ember-cli-deploy-github-deployments",

0 commit comments

Comments
 (0)