Skip to content
Articles

How to deploy your code

This is extremely helpful when you're working locally. Create a deployment to watch your dev branch and every time you push a commit it will be automatically pushed to your staging site.

Does your production site run on more than one server? Setup a deployment that pushes to them both at the same time.

Do you have a more complicated deployment process that requires running a database migration or other custom script? A deployment can handle that for you automatically.

There are a couple services that can help make deployments easier, Beanstalk and DeployHQ.

Comparing Beanstalk and DeployHQ

Beanstalk has a much cleaner interface and more deployment options than DeployHQ. It also provides hosting for your repositories, which DeployHQ does not. However, it can only deploy its own repositories. For example, you can’t deploy a GitHub repository.

DeployHQ is focused only on deployment. It doesn’t provide repository hosting. I find the interface to be clunkier than Beanstalk. But, it can deploy repositories that are hosted just about anywhere.

We used Beanstalk for a long time, but recently switched to GitHub for repository hosting and DeployHQ for deployment. We’ve found that what DeployHQ lacks in ease of use, GitHub more than makes up for in its social coding features (pull requests, comments, etc). But really, both services offer adequate solutions.

Configuring Deployments with Beanstalk

Beanstalk deployment
Beanstalk's deployment overview

To set up a deployment on Beanstalk:

  1. Go to the Deployments tab for your repository
  2. Click Add Environment
  3. Configure a development, staging or production environment by giving it the proper name and selecting the correct branch.
  4. Set the Deployment Mode to Automatic for development or staging environments or Manual for production environments.
  5. Add one or more servers by selecting your destination (e.g. FTP, SFTP, Heroku, Amazon S3, etc) and then providing the proper credentials.

Read Beanstalk’s Deployment Best Practices guide and knowledge base article for more details.

Deploy hq
Beanstalk deployment options
Beanstalk's deployment options

Configuring Deployments with DeployHQ + GitHub

To setup DeployHQ to deploy a GitHub repository:

  1. Create a new project in DeployHQ
  2. Select the GitHub repository tab
  3. Enter your GitHub username and password
  4. Select the GitHub repository you want to deploy
  5. Add server information like FTP/SFTP, environment, branch, path, username and password and save your settings
DeployHQ's deploy hook URL

If you want to setup auto deployment:

  1. Go to Settings > Servers and Groups for your project and click the server you just setup
  2. Copy the Deploy Hook URL from the sidebar
  3. In GitHub, go to your repository and click Settings > Service Hooks > Webhook URLs
  4. Paste the Deploy Hook URL into the URL field and Update Settings

Read DeployHQ’s article on Using Automatic Deployments for more details.