Skip to content

smithfield-studio/trellis-slack-deploy-notifications

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Trellis Slack Deploy Notifications

Sends notifications to Slack before & after deployments via Trellis. Forked from trellis-slack-webhook-notify-during-deploy.

Requirements

  • Trellis v1.0.0 or later
  • Trellis CLI
  • Ansible v2.6 or later
  • Slack webhook token

Screenshots

Deployment Screenshot

Installation

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

Update Deploy Hooks

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: #...

Running via GitHub Actions / CI

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 }}

FAQs

How do I get a Slack Webhook URL?

  1. Visit the "Your Apps" page on Slack
  2. Create an App (e.g. "Deployment alerts") and enable "Incoming Webhooks"
  3. Setup a Webhook for your desired Workspace
  4. 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.

See Also

About

Sends notifications to Slack before & after deployments via Trellis.

Resources

License

Stars

Watchers

Forks