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:

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

This will copy the file to the stack path so we have access to the git repository information. The 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 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