This is a brief description of how to get CircleCI builds deployed to an Engine Yard hosted staging environment automatically.
We're essentially asking CircleCI to execute commands on the Engine Yard gem to ask EY to deploy a Rails app.
CircleCI needs an SSH key and an API token to talk to Engine Yard, at that point you can execute the deploy command on the gem when the build succeeds.
- Create a new ssh key and upload the public key to your SSH keys in Engine Yard. Apply the change to your environment.
tim@factory:~ $ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/tim/.ssh/id_rsa): /Users/tim/.ssh/cci_rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/tim/.ssh/cci_rsa. Your public key has been saved in /Users/tim/.ssh/cci_rsa.pub. The key fingerprint is: dc:da:81:77:e9:c2:db:ec:17:4e:87:c0:ab:37:7d:9f tim@factory.local The key's randomart image is: +--[ RSA 2048]----+ | | | | | . | | . o o. | | S + oo . | | = +. + .| | . +..+ o | | .=o + o| | .o+o Eo| +-----------------+ tim@factory:~ $ cat ~/.ssh/cci_rsa.pub | pbcopy 2. Add the new private key to CircleCI. This allows CircleCI to talk to Engine Yard.
tim@factory:~ $ cat ~/.ssh/cci_rsa | pbcopy
- Add new key in the
SSH Permissions
section of the Settings for the build
- Add the
gem 'engineyard'
to your Gemfile and runbundle
- Log into the Engine Yard CLI and grab your API token for CircleCI to use.
bundle exec ey login
bundle exec ey init
-
cat ~/.eyrc --- api_token: 76f2d43d79bedd9bc74654a1ded733c9
- Add that API token as an environment variable in CircleCI called
ENGINE_YARD_API_TOKEN
- Create a file called
circle.yml
in yourRAILS_ROOT
this will deploy any successful commits to yourmaster
branch over to yourstaging
environment.
-
deployment: staging: branch: master commands: - bundle exec ey deploy --api-token=${ENGINE_YARD_API_TOKEN}
- Commit everything and it should then deploy to Engine Yard after a green build.