Development + Deployment with Codebase and DeployHQ

Last updated by Adam West on April 11, 2018 15:14

This article is going to describe a a development and deployment workflow using Codebase and DeployHQ and provide instructions on how to set it up. The following scenario should work for Git and Mercurial users. Unfortunately it doesn't apply to Subversion due to the lack of proper branches.

DeployHQ is a repository to server deployment solution. It can take a working copy of your repository and push the changed files since the previous deployment to your server via FTP or SFTP. If you haven't set yours up yet, just sign up for a new account on the DeployHQ and get in touch with us, then we can activate it for you.

We'll assume your repository has 3 remote branches on Codebase; master (for development), testing and production. Development work can be done on local branches and merged into master before pushing, or directly ontomaster. We want to automatically deploy changes that are made to the master and testing branches, but not those on the production branch.

Assuming a 3-man development team, we want our repository and server layout to look something like this:

Repository layout

The first step is to create a new project in DeployHQ, and introduce it to our Codebase repository. Create a new empty project in the DeployHQ interface click Select a Codebase repository, enter your Codebase credentials and select your repository. Now set up a profile for your development, testing and live servers. The key field to pay attention to is Branch to deploy from. This field locks your server to that branch, it will only deploy changes from that branch, and automatic deployments will only be triggered by changes to that branch.

You'll want to map the appropriate branch to each server, so:

  • master => devel.oursite.com
  • testing => testing.oursite.com
  • production => live.oursite.com

Next head to the edit page for each of these servers and find the DeployHQ Hook box at the bottom of the page. Make sure auto-deploy is set to Off for the live server. Make a note of the URLs listed for the 2 servers that we want to auto-deploy to, we're going to tell Codebase about them now.

Open your repository up in Codebase (there's a shortcut on the left hand side of your DeployHQ project labelled Browse Repository) and open the Repository Admin/Properties. Enter the URLs from the DeployHQ Hook boxes into the Post-Receive Hooks form (there's no need to add any authentication details).

With this set up Codebase and DeployHQ will now work together to automatically push changes to your development and testing servers automatically, and when the production branch is ready to be pushed to your live server you can just log into DeployHQ as usual and press Deploy Now.