Skip to content

Instantly share code, notes, and snippets.

@timharding
Last active December 14, 2016 12:54
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timharding/5a6c59430ca79155c293 to your computer and use it in GitHub Desktop.
Save timharding/5a6c59430ca79155c293 to your computer and use it in GitHub Desktop.
CircleCI to Engine Yard Continuous Deployment

Configuring CircleCI to deploy to Engine Yard

Preamble

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.

In brief

  1. 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
  1. Add the gem 'engineyard' to your Gemfile and run bundle
  2. 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
    
  1. Add that API token as an environment variable in CircleCI called ENGINE_YARD_API_TOKEN
  2. Create a file called circle.yml in your RAILS_ROOT this will deploy any successful commits to your master branch over to your staging environment.
  • deployment:
      staging:
        branch: master
        commands:
          - bundle exec ey deploy --api-token=${ENGINE_YARD_API_TOKEN}
    
  1. Commit everything and it should then deploy to Engine Yard after a green build.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment