Skip to content

Commit

Permalink
Release 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
LevelbossMike committed Jun 14, 2015
1 parent 2e2f6c2 commit 6354752
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 19 deletions.
82 changes: 68 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,79 @@
# Ember-cli-deploy-slack

This README outlines the details of collaborating on this Ember addon.
An ember-cli-deploy-plugin for sending deployment messages to [Slack](https://slack.com/).

## Installation
## Usage

* `git clone` this repository
* `npm install`
* `bower install`
This plugin will only work with the upcoming 0.5.0-release of
[ember-cli-deploy](https://github.com/ember-cli/ember-cli-deploy). Right now
you have to use my [didFail branch](levelbossmike/ember-cli-deploy#didFail-hook-).

## Running
To setup ember-cli-deploy-slack you need to add a `slack`-entry into your
`deploy.js` configuration file:

* `ember server`
* Visit your app at http://localhost:4200.
```js
module.exports = function(environment) {
var environments = {
"development": {
// ...
"slack": {
"webhookURL": "https://hooks.slack.com/services/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",
"channel": "#notifications",
"username": "ember-cli-deploy"
},
// ...
},

## Running Tests
"staging": {
// ...
},

* `ember test`
* `ember test --server`
"production": {
// ...
}
};

## Building
return environments[environment];
};
```

* `ember build`
## Customization

For more information on using ember-cli, visit [http://www.ember-cli.com/](http://www.ember-cli.com/).
`ember-cli-deploy-slack` will send default messages on the `didDeploy`- and
`didFail`-hooks on the pipeline. Because every team is different and people
tend to customize their automatic slack notifications messages can be
customized.

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": "https://hooks.slack.com/services/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",
"channel": "#notifications",
"username": "ember-cli-deploy",
"didDeploy": function(context, slack) {
return slack.notify({
text: 'w00t I can haz custumizations!'
});
}
},
// ...
},
```
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.
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
`willDeploy`, `willBuild`, `build`, `didBuild`, `willActivate`, `activate`,
`didActivate`, `didDeploy`, `didFail`
44 changes: 41 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ var yellow = chalk.yellow;

function applyDefaultConfigIfNecessary(config, prop, defaultConfig, ui){
if (!config[prop]) {
var value = defaultConfig[prop];
var value = defaultConfig[prop] || function() { return; };
config[prop] = value;
ui.write(blue('| '));
ui.writeLine(yellow('- Missing config: `' + prop + '`, using default: `' + value + '`'));
if (defaultConfig[prop]) {
ui.write(blue('| '));
ui.writeLine(yellow('- Missing config: `' + prop + '`, using default: `' + value + '`'));
}
}
}

Expand Down Expand Up @@ -63,6 +65,42 @@ module.exports = {
return executeSlackNotificationHook.bind(this)(context, 'willDeploy');
},

willBuild: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'willBuild');
},

build: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'build');
},

didBuild: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'didBuild');
},

willUpload: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'willUpload');
},

upload: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'upload');
},

didUpload: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'didUpload');
},

willActivate: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'willActivate');
},

activate: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'activate');
},

didActivate: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'didActivate');
},

didDeploy: function(context) {
return executeSlackNotificationHook.bind(this)(context, 'didDeploy');
},
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"name": "ember-cli-deploy-slack",
"version": "0.0.0",
"description": "The default blueprint for ember-cli addons.",
"version": "0.0.1",
"description": "An ember-cli-deploy-plugin for sending messages to Slack",
"directories": {
"doc": "doc",
"test": "tests"
},
"repository": "https://github.com/LevelbossMike/ember-cli-deploy-slack",
"scripts": {
"start": "ember server",
"build": "ember build",
Expand Down

0 comments on commit 6354752

Please sign in to comment.