Skip to content

Commit

Permalink
Merge pull request #6 from LevelbossMike/master
Browse files Browse the repository at this point in the history
Update documentation
  • Loading branch information
Aaron Chambers committed Oct 18, 2015
2 parents c77f624 + d428dd1 commit 057b347
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 55 deletions.
163 changes: 110 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,77 @@
# 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)

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

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

To setup ember-cli-deploy-slack you need to add a `slack`-entry into your
`deploy.js` configuration file:
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.

```js
module.exports = function(environment) {
var environments = {
"development": {
// ...
"slack": {
"webhookURL": "<your-webhook-URI>",
"channel": "#notifications",
"username": "ember-cli-deploy"
},
// ...
},

"staging": {
// ...
},

"production": {
// ...
}
};

return environments[environment];
};
For more information on what plugins are and how they work, please refer to the [Plugin Documentation][2].

## Quick Start

To get up and running quickly, do the following:

- Install this plugin

```bash
$ ember install ember-cli-deploy-slack
```

- Create a [webhook](https://api.slack.com/incoming-webhooks) in Slack.

- Place the following configuration into `config/deploy.js`

```javascript
ENV.slack = {
webhookURL: '<your-webhook-URI>'
}
```

- Run the pipeline

```bash
$ ember deploy
```

## ember-cli-deploy Hooks Implemented

For detailed information on what plugin hooks are and how they work, please refer to the [Plugin Documentation][2].

- `configure`
- `willDeploy`
- `willBuild`
- `build`
- `didBuild`
- `willUpload`
- `upload`
- `didUpload`
- `willActivate`
- `activate`
- `didActivate`
- `didDeploy`
- `didFail`

## Configuration Options

For detailed information on how configuration of plugins works, please refer to the [Plugin Documentation][2].

###webhookURL

The [webhook](https://api.slack.com/incoming-webhooks) in Slack that the plugin will notify.

###channel

The channel in slack that the notification should be displayed in in Slack.

###username

The username that will send the message in Slack.

## Customization

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

```js
module.exports = function(environment) {
var environments = {
"development": {
// ...
"slack": {
"webhookURL": "<your-webhook-URI>",
"channel": "#notifications",
"username": "ember-cli-deploy",
"didDeploy": function(context) {
return function(slack) {
return slack.notify({
text: 'w00t I can haz custumizations!'
});
};
},
},
// ...
},
ENV.slack = {
webhookURL: '<your-webhook-URI>',
channel: '#notifications',
username: 'ember-cli-deploy',
didDeploy: function(context) {
return function(slack) {
return slack.notify({
text: 'w00t I can haz customizations!'
});
};
}
}
```

Notification hooks will be passed the deployment context and the slackNotifier
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.
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.

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:

```javascript
ENV.slack = {
webhookURL: '<your-webhook-URI>',
willDeploy: function(context) {
return function(slack) {
return {
slackStartDeployDate: new Date()
};
};
},

didDeploy: function(context) {
return function(slack) {
var start = context.slackStartDeployDate;
var end = new Date();
var duration = (end - start) / 1000;

return slack.notify({
text: 'Deploy took '+duration+' seconds'
});
};
}
}
```

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

### Available hooks
## Running Tests

- `npm test`

`willDeploy`, `willBuild`, `build`, `didBuild`, `willActivate`, `activate`,
`didActivate`, `didDeploy`, `didFail`
[2]: http://ember-cli.github.io/ember-cli-deploy/plugins "Plugin Documentation"
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
'use strict';

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

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
"ember-cli-deploy-plugin": "0.1.1",
"moment": "^2.10.3",
"moment-duration-format": "^1.3.0",
"node-slackr": "^0.1.0"
"node-slackr": "^0.1.0",
"silent-error": "^1.0.0"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down

0 comments on commit 057b347

Please sign in to comment.