Here at Shippable we love taking customers all the way to continuous deployment. We've detailed a variety of different ways to get there in the past, and today we are going to be bringing out yet another way. Today we'll be showing you how to trigger your Shippable builds, to push your rails apps to Engine Yard.
Before going any further, there are a few pre-reqs:
- An active Engineyard account
- A working rails app on github
- An active Shippable account
- The above rails app being enabled on Shippable
- An application env already setup on Engine Yard
What I mean by that last step is you can already deploy your app manually through the Engine Yard GUI.
The first step is to grab an API token. This can be done by installing the engine yard gem on your local system, logging in, and extracting the token from the file it writes to your system. For example:
> gem install engineyard
> ey login
We need to fetch your API token; please log in...
> cat ~/.eyrc
You must also add your Shippable deployment key to Engine Yard. Your Shippable deployment key can be found your account or orgs page inside the Shippable console. Copy this key when you find it. You can then add ssh keys to your Engine Yard account under tools -> SSH public keys. You must also attach this key to your Engine Yard environment, and deploy the configuration. Details can be found on their docs.
Additionally, if you haven't done so already run ey init in your rails app. And commit the resulting config/ey.yml file to git.
You must then augment your shippable.yml file for the deployment. The first step to encrypt your api token through the Shippable console. If you're unsure about how to do this, please refer to our documentation. Encrypt the env var with the name token, and place the result in the global env section of your shippable.yml file
- secure: ...
Then install the engineyard gem on your minion in the before_install section. We need the ey command to later be available to us.
before_install: - gem install engineyard
Finally, you must trigger ey deploy in the after_success section. You must also enable ssh-agent and add your key to it. Engine Yard depends on ssh agent forwarding for its deployments, and your deploy won't work without that extra step.
- ssh-agent bash -c "ssh-add /home/shippable/.ssh/id_rsa; ey deploy --api-token=$token"
Feel free to checkout my example code on Github: https://github.com/CADBOT/engineyard-sample
Most of these steps apply to other Engine Yard supported application stacks as well, so feel free to experiment!