Skip to content

Commit 057b347

Browse files
author
Aaron Chambers
committed
Merge pull request #6 from LevelbossMike/master
Update documentation
2 parents c77f624 + d428dd1 commit 057b347

File tree

3 files changed

+113
-55
lines changed

3 files changed

+113
-55
lines changed

README.md

Lines changed: 110 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,77 @@
11
# Ember-cli-deploy-slack [![Build Status](https://travis-ci.org/ember-cli-deploy/ember-cli-deploy-slack.svg?branch=master)](https://travis-ci.org/ember-cli-deploy/ember-cli-deploy-slack)
22

3-
An ember-cli-deploy-plugin for sending deployment messages to [Slack](https://slack.com/).
3+
> An ember-cli-deploy-plugin for sending deployment messages to [Slack](https://slack.com/).
44
5-
## Usage
5+
<hr/>
6+
**WARNING: This plugin is only compatible with ember-cli-deploy versions >= 0.5.0**
7+
<hr/>
68

7-
This plugin will only work with the upcoming 0.5.0-release of
8-
[ember-cli-deploy](https://github.com/ember-cli/ember-cli-deploy).
9+
## What is an ember-cli-deploy plugin?
910

10-
To setup ember-cli-deploy-slack you need to add a `slack`-entry into your
11-
`deploy.js` configuration file:
11+
A plugin is an addon that can be executed as a part of the ember-cli-deploy pipeline. A plugin will implement one or more of the ember-cli-deploy's pipeline hooks.
1212

13-
```js
14-
module.exports = function(environment) {
15-
var environments = {
16-
"development": {
17-
// ...
18-
"slack": {
19-
"webhookURL": "<your-webhook-URI>",
20-
"channel": "#notifications",
21-
"username": "ember-cli-deploy"
22-
},
23-
// ...
24-
},
25-
26-
"staging": {
27-
// ...
28-
},
29-
30-
"production": {
31-
// ...
32-
}
33-
};
34-
35-
return environments[environment];
36-
};
13+
For more information on what plugins are and how they work, please refer to the [Plugin Documentation][2].
14+
15+
## Quick Start
16+
17+
To get up and running quickly, do the following:
18+
19+
- Install this plugin
20+
21+
```bash
22+
$ ember install ember-cli-deploy-slack
3723
```
3824

25+
- Create a [webhook](https://api.slack.com/incoming-webhooks) in Slack.
26+
27+
- Place the following configuration into `config/deploy.js`
28+
29+
```javascript
30+
ENV.slack = {
31+
webhookURL: '<your-webhook-URI>'
32+
}
33+
```
34+
35+
- Run the pipeline
36+
37+
```bash
38+
$ ember deploy
39+
```
40+
41+
## ember-cli-deploy Hooks Implemented
42+
43+
For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][2].
44+
45+
- `configure`
46+
- `willDeploy`
47+
- `willBuild`
48+
- `build`
49+
- `didBuild`
50+
- `willUpload`
51+
- `upload`
52+
- `didUpload`
53+
- `willActivate`
54+
- `activate`
55+
- `didActivate`
56+
- `didDeploy`
57+
- `didFail`
58+
59+
## Configuration Options
60+
61+
For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][2].
62+
63+
###webhookURL
64+
65+
The [webhook](https://api.slack.com/incoming-webhooks) in Slack that the plugin will notify.
66+
67+
###channel
68+
69+
The channel in slack that the notification should be displayed in in Slack.
70+
71+
###username
72+
73+
The username that will send the message in Slack.
74+
3975
## Customization
4076

4177
`ember-cli-deploy-slack` will send default messages on the `didDeploy`- and
@@ -47,34 +83,55 @@ To customize a message you simply add a function to your slack configuration
4783
options that is named the same as the hook notification you want to customize:
4884

4985
```js
50-
module.exports = function(environment) {
51-
var environments = {
52-
"development": {
53-
// ...
54-
"slack": {
55-
"webhookURL": "<your-webhook-URI>",
56-
"channel": "#notifications",
57-
"username": "ember-cli-deploy",
58-
"didDeploy": function(context) {
59-
return function(slack) {
60-
return slack.notify({
61-
text: 'w00t I can haz custumizations!'
62-
});
63-
};
64-
},
65-
},
66-
// ...
67-
},
86+
ENV.slack = {
87+
webhookURL: '<your-webhook-URI>',
88+
channel: '#notifications',
89+
username: 'ember-cli-deploy',
90+
didDeploy: function(context) {
91+
return function(slack) {
92+
return slack.notify({
93+
text: 'w00t I can haz customizations!'
94+
});
95+
};
96+
}
97+
}
6898
```
6999

70-
71100
Notification hooks will be passed the deployment context and the slackNotifier
72-
utility class. The SlackNotifier uses [node-slackr](https://github.com/chenka/node-slackr) under the hood so you can use its `notify`-function accordingly. This enables you to customize your messages in any way possible. You can even add custom properties to the deployment context if that's what you need to do.
101+
utility class. The SlackNotifier uses [node-slackr](https://github.com/chenka/node-slackr) under the hood so you can use its `notify`-function accordingly. This enables you to customize your messages in any way possible.
102+
103+
Because of the way `ember-cli-deploy` merges return values of hooks back into the deployment context, you can easily add custom properties to the deployment context if that's what you need to do:
104+
105+
```javascript
106+
ENV.slack = {
107+
webhookURL: '<your-webhook-URI>',
108+
willDeploy: function(context) {
109+
return function(slack) {
110+
return {
111+
slackStartDeployDate: new Date()
112+
};
113+
};
114+
},
115+
116+
didDeploy: function(context) {
117+
return function(slack) {
118+
var start = context.slackStartDeployDate;
119+
var end = new Date();
120+
var duration = (end - start) / 1000;
121+
122+
return slack.notify({
123+
text: 'Deploy took '+duration+' seconds'
124+
});
125+
};
126+
}
127+
}
128+
```
73129

74130
Please see the [Slack API documentation for message formatting](https://api.slack.com/docs/formatting)
75131
to see how you can customize your messages.
76132

77-
### Available hooks
133+
## Running Tests
134+
135+
- `npm test`
78136

79-
`willDeploy`, `willBuild`, `build`, `didBuild`, `willActivate`, `activate`,
80-
`didActivate`, `didDeploy`, `didFail`
137+
[2]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
'use strict';
33

44
var Promise = require('ember-cli/lib/ext/promise');
5-
var SilentError = require('ember-cli/lib/errors/silent');
5+
var SilentError = require('silent-error');
66
var SlackNotifier = require('./lib/slack-notifier');
77
var DeployPluginBase = require('ember-cli-deploy-plugin');
88

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"ember-cli-deploy-plugin": "0.1.1",
5151
"moment": "^2.10.3",
5252
"moment-duration-format": "^1.3.0",
53-
"node-slackr": "^0.1.0"
53+
"node-slackr": "^0.1.0",
54+
"silent-error": "^1.0.0"
5455
},
5556
"ember-addon": {
5657
"configPath": "tests/dummy/config"

0 commit comments

Comments
 (0)