This is a slight reworking of the Quicksilver script for integrating Pantheon with Slack notifications. It fixes a problem where commit messages were not being sent to Slack. It also includes stronger differentiation between the actions commit, deploy and clear cache in the Slack channel and cuts out some things (which can be uncommented) to keep the information succinct and useful.
A slightly altered version of the original README continues below.
This script shows how easy it is to integrate Slack notifications from your Pantheon project using Quicksilver. As a bonus, we also show you how to manage API keys outside of your site repository.
- Enable Incoming Webhooks for your Slack instance.
- Copy the secret Webhook URL into a file called
secrets.jsonand store it in the private files directory of every environment where you want to trigger Slack notifications.
$> echo '{"slack_url": "https://hooks.slack.com/services/MY/SECRET/URL"}' > secrets.json
# Note, you'll need to copy the secrets into each environment where you want to trigger Slack notifications.
$> `terminus connection:info --field=sftp_command site.env`
Connected to appserver.dev.d1ef01f8-364c-4b91-a8e4-f2a46f14237e.drush.in.
sftp> cd files
sftp> mkdir private
sftp> cd private
sftp> put secrets.json
sftp> quit- Add, and update as needed, the example
slack_pantheon.phpscript to theprivatedirectory in the root of your site's codebase, that is under version control. Note this is a differentprivatedirectory than where the secrets.json is stored. - Add Quicksilver operations to your
pantheon.yml - Test a deploy out!
Optionally, you may want to use the terminus workflows watch command to get immediate debugging feedback. You may also want to customize your notifications further. The Slack API documentation has more on your options.
Here's an example of what your pantheon.yml would look like if this were the only Quicksilver operation you wanted to use. Pick and choose the exact workflows that you would like to see notifications for.
api_version: 1
workflows:
deploy_product:
after:
- type: webphp
description: Post to Slack after site creation
script: private/scripts/slack_pantheon.php
create_cloud_development_environment:
after:
- type: webphp
description: Post to Slack after Multidev creation
script: private/scripts/slack_pantheon.php
deploy:
after:
- type: webphp
description: Post to Slack after deploy
script: private/scripts/slack_pantheon.php
sync_code:
after:
- type: webphp
description: Post to Slack after code commit
script: private/scripts/slack_pantheon.php
clear_cache:
after:
- type: webphp
description: Someone is clearing the cache again
script: private/scripts/slack_pantheon.php