Maintain deploy announcements in Slack channels.
First you need to add a new slash command for your team:
- Go to Custom Integrations and click on "New Command"
- In the "Command" field type in /deploy — this will be your new Slack command to start, finish and list deploys in channel
- Fill in "URL" field with an URL where
slack-deploy-command
is deployed - Set "Method" to
POST
- Copy the content of "Token" field, this will be needed to authenticate incoming requests
You may also like to customize name, icon and include this command into autocomplete list.
Now the server part. To execute a slash command Slack sends a request to an URL associated with it and outputs the response.
Slack requires this URL to be an HTTPS, so you will need some reverse-proxy (such as nginx
, caddy
, etc.) configured to serve HTTPS requests.
Self-signed certificates won't work for Slack, Letsencrypt might be a good option to obtain a real one.
Now compile and run the server (assuming that you have go
installed):
go get github.com/andrewslotin/slack-deploy-command
SLACK_TOKEN=<token you copied before> $GOPATH/bin/slack-deploy-command
This will run a server listening on 0.0.0.0:8081
. Check $GOPATH/bin/slack-deploy-command --help
to see available options.
Optionally you may provide your GitHub personal access token with repo
permissions by
setting GITHUB_TOKEN
environment variable. This token is used to get PR details (title, description and author) and attach them to an announcement.
If no token is provided only public pull requests will be have detailed information, and others will only contain a link to GitHub.
Deploys are tracked per channel. This means that different channels can run different deploys at the same time.
-
/deploy status — see if there is a deploy currently running.
-
/deploy <subject> — initiate a deploy in the channel. is an arbitrary string describing what's being deployed.
If there is already a deploy announced by another user in this channel, it needs to be finished first.
However if you already initiated a deploy the channel, you can update its subject by executing this command again.
-
/deploy done — finish current deploy.
In addition to announcing deploys in channel you may find it useful to have a small sign in the channel topic. This way you can quickly check
if it's safe to deploy. Slack deploy command uses ✅ and ⛔ to mark channel as clear for deployment and show that there
is a deploy in progress. To use this feature you need to provide Slack Web API token in
SLACK_WEBAPI_TOKEN
environment variable and add either :white_check_mark:
or :no_entry:
to the channel topic. Whenever the deploy changes
the deploy bot will swap these emojis.
To disable this feature without re-deploying the whole service simply remove emojis from channel topic.
To keep the deploy status between service restarts you might want to use built-in BoltDB database. To do this you need to specify the path to
your BoltDB file in BOLTDB_PATH
environment variable.
BOLTDB_PATH=/path/to/your/bolt.db $GOPATH/bin/slack-deploy-command
This software is distributed under LGPLv3 license. You can find the full text in LICENSE.