Skip to content

Commit ed6c1a5

Browse files
committed
Add tip how to use deploy context in README
1 parent cf0a847 commit ed6c1a5

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,34 @@ ENV.slack = {
9898
```
9999

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

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

0 commit comments

Comments
 (0)