Sends notifications to Slack before & after deployments via Trellis. Forked from trellis-slack-webhook-notify-during-deploy.
- Trellis v1.0.0 or later
- Trellis CLI
- Ansible v2.6 or later
- Slack webhook token
Add the role to galaxy.yml
+ check for the latest version.
---
roles:
#...
- name: trellis-slack-deploy-notifications
src: https://github.com/smithfield-studio/trellis-slack-deploy-notifications
version: 1.0.1
Ensure you have Trellis CLI installed, then run:
trellis galaxy install
Add the start & success tasks to the deploy_before
& deploy_after
deploy hooks in roles/deploy/defaults/main.yml
.
deploy_before:
- '{{ playbook_dir }}/vendor/roles/trellis-slack-deploy-notifications/tasks/deploy_start.yml'
#...
deploy_after:
- '{{ playbook_dir }}/vendor/roles/trellis-slack-deploy-notifications/tasks/deploy_success.yml'
Add your Slack webhook token(s) (end of the webhook URL) and channel into group_vars/{environment}/vault.yml
vault_wordpress_sites:
example.com.au:
slack_deploy_token:
- xxx/xxx/xxxxx
- xxx/xxx/xxxxx
env: #...
See setup-trellis-cli to get the workflow setup. Then add the CI_JOB_URL
to env var to your deploy workflow to include a link back to the running GitHub Action in the start notification.
name: Deploy site
env:
CI_JOB_URL: ${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
- Visit the "Your Apps" page on Slack
- Create an App (e.g. "Deployment alerts") and enable "Incoming Webhooks"
- Setup a Webhook for your desired Workspace
- Copy the token from the Webhook URL for use in Installation
Note: Each Webhook can only post to one channel since Slack changed their API. You will need to set up a webhook per channel you wish to notify.