How to deploy your code
If you use a source code repository like Git or Subversion and have to push code manually you're missing out. There are deployment tools that can save you a lot of time. You can also set up automatic deployment so that every time you push a commit to your repository the change gets automatically deployed to your server.
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
To set up a deployment on Beanstalk:
- Go to the Deployments tab for your repository
- Click Add Environment
- Configure a development, staging or production environment by giving it the proper name and selecting the correct branch.
- Set the Deployment Mode to Automatic for development or staging environments or Manual for production environments.
- Add one or more servers by selecting your destination (e.g. FTP, SFTP, Heroku, Amazon S3, etc) and then providing the proper credentials.
Configuring Deployments with DeployHQ + GitHub
To setup DeployHQ to deploy a GitHub repository:
- Create a new project in DeployHQ
- Select the GitHub repository tab
- Enter your GitHub username and password
- Select the GitHub repository you want to deploy
- Add server information like FTP/SFTP, environment, branch, path, username and password and save your settings
If you want to setup auto deployment:
- Go to Settings > Servers and Groups for your project and click the server you just setup
- Copy the Deploy Hook URL from the sidebar
- In GitHub, go to your repository and click Settings > Service Hooks > Webhook URLs
- Paste the Deploy Hook URL into the URL field and Update Settings
Read DeployHQ’s article on Using Automatic Deployments for more details.