AppSignal deploy notification with Cloud66 deploy hook

If you are using AppSignal and your are deploying your app with Cloud66 you miss out on the default (capistrano or heroku) deploy notifications. Luckely both systems provide ways to make it happen and it's real easy to!

On Cloud66 you can use deployment hooks to do whatever you like. Read more about it here.

You need to add a .cloud66 folder to your application and place a file there named deploy_hooks.yml. An example (production) deploy hook is listed below:

production:  
    last_thing:
      - source: /.cloud66/appsignal_deploy.sh
        destination: <%= ENV['STACK_PATH'] %>/appsignal_deploy.sh
        target: rails
        execute: true
        sudo: true

This will copy the appsignal_deploy.sh file to the stack path so we have access to the git repository information. The appsignal_deploy.sh file gets the latest commit sha and the author from that commit and then uses the CLI from the Appsignal gem to notify AppSignal that the deployment was done.

The appsignal_deploy.sh is listed below:

last_commit=$(git rev-parse HEAD)  
author=$(git --no-pager show -s --format='%an <%ae>' $last_commit)  
bundle exec appsignal notify_of_deploy --revision=$last_commit --user=$author --environment=$RACK_ENV  

Make sure to update to appsignal version 0.8.5 since it does not require you to use the --repository option anymore. You might get errors if you don't