Copyright © 2016, Brendan Doms
Licensed under the MIT license
A hook to automatically notify Slack when a git push happens.
You are creating a new release of your product. This usually happens simultaneously with pushing to a branch. Developers and others who get notified of pushes might know about this, but non-technical people probably don't. And there might not be a good list of what's changed.
Time to increase visibility.
This pre-push hook notifies Slack that a new release is going out, and it optionally provides a list of included changes in the form of Trello cards.
Copy the pre-push
file to your repo's .git/hooks/pre-push
or integrate it with an existing file if you already have one.
Make sure that the import line will work correctly for where you put this project.
Then replace all of the arguments in the hook with your own values.
See the Slack submodule
for instructions on creating the webhook for the url
parameter.
By default all branches are considered valid,
but if you specify one then only pushes for that branch send notifications.
Typically you would set this to master
to only notify when that branch is pushed.
By default all remotes are considered valid,
but if you specify one then only pushes to that remote send notifications.
For example, you might set this to heroku
to only notify when pushing to that remote.
Defaults to New release deployed by %s
where the current git username is interpolated.
By default printing is suppressed.
Set verbose
to True
to get more information about all the actions being taken.
If included, this should be a list of JSON-style dictionaries representing Trello cards. They will be attached to the Slack message as a list of short names, each linking to the relevant card. They will be styled as an unordered list, but they will still preserve their order when displayed.
If the provided cards have labels then the colors can be included as part of the Slack message. As these colors can be changed by the user, you must provide them for this feature to work. They should be formatted as a dictionary of color names to hex color values. To see an example, my Trello project includes the default set.