This article is part of a series created in partnership with SiteGround. Thank you for supporting the partners who make SitePoint possible.
The Problem: Deploying Code
So you have your projects in GitHub, whatever they are — an app you’re working on with a small team, a small business brochure site, an ecommerce platform. You’ve decided to version control them, but you still have little in the way of automated processes in place, and you’re still having to update each of your environments — staging, production, whatever you have — by hand, with FTP. Or you’ve got them pulling down Git changes from a branch.
This pain is only multiplied if you’re deploying to other development or staging servers too, or you have a load-balanced production machine that needs multiple simultaneous deployments. What you really need is an automated process here, that can either automatically deploy when changes to code are made, or can be ready to do so at the push of a button.
The Solution: DeployHQ
DeployHQ can be the link between your Git repository and your servers and do your deployments for you. You can make those deployments automatic (every time you commit to your
staging branch, DeployHQ automatically deploys those changes to your Staging server). You can also trigger deployments manually (deploying to Production server from the
production branch requires you to push the button yourself). This flexibility allows for a maximum of convenience and automaton without taking important safeguards away, like a review of code merged into production, or the schedule by which you update your production website.
DeployHQ seems especially good for a small company or developer who doesn’t have all of their testing, builds, CI, etc automated yet into cohesive processes, and is really looking for a way to push code to various environments with as little friction as possible.
Getting Started with DeployHQ
When you sign up for your DeployHQ account, you’ll login and arrive at the welcome screen.
Then, you’ll need to follow a few steps in order to get your deployments up and running!
In the below examples of configuration, GitHub will be used as the version control system. So, head over to GitHub, and if you don’t already have a project in mind, create a repository. The repository, ideally, will have multiple branches (i.e. “staging”, “production”) just to help demonstrate the functionality available at DeployHQ. Both staging and production branches of a test repository will be used in this demonstration. You can leave this open in a tab, as you’ll need to come back.
2. Create a New DeployHQ Project
Right from the welcome screen, hit the “Create a new project” button.
You’ll need to give the project a name, and choose the version control system that you’re using. For this example, we’re using GitHub. Then, hit “Create Project”! You’ll see a progress screen, and then, if all goes well, you’ll get a screen that requires you to login (or if already logged in, authorize the app) to access your repository.
Once you’ve authorized DeployHQ to access your GitHub, you’ll be taken to a screen which shows the organizations you’re connected to (and your personal repositories) with a list of those repositories. Pick one to link your project to, and once this is done, DeployHQ will ask you to provide server information.
3. Adding a Server
To add a server, you’ll give it an internal name, then pick the protocol with which you’d like to access the server, such as
Once you’ve made a choice, more options will open up, where you can fill out information about your website hosting, details like the server’s IP and credentials, the path from the FTP root to get to your website files, etc.
If you have enough active servers on DeployHQ that you need to group them, you’ll be able to choose a group for this server. You’ll also want to choose which branch of the repository the project is linked to you’ll want to deploy from. Picking
staging will mean that when code is committed to the
staging branch in GitHub, DeployHQ will be picking that up and able to deploy using it.
Now that you’ve added your server, click the edit button to edit the server in DeployHQ. You’ll see here both the settings you’ve already chosen for the server, as well as a few more, particularly along the right sidebar.
There may be things that you don’t want entirely automatically deployed. For example, your production branch might need to be vetted or go through a final test run before you push it live, or you may have to do so on a schedule. No problem. Simply toggle off automatic deployments for this server in the settings menu on the right.
Then, after pushing some code to the appropriate GitHub branch, you’ll be able to zip over to your DeployHQ project and deploy it manually with just a click or two!
This test site started out with nothing in it. After initializing the GitHub with a starter
index.html and then hitting “deploy” on DeployHQ, here’s what we have:
On the other hand, maybe you want your staging environment to just automatically push changes to the server as soon as you make them in GitHub. Head over and look at that server edit screen, at the right side panel. You’ll see the “Automatic Deployment” option — toggle that on. You’ll also want to copy the URL below it. In the same area, you’ll see that DeployHQ has documentation about automatic deployments to assist if you run into any snags.
Now, pop back over to your GitHub repository and go to the repository’s settings, and Webhooks. Add a new Webhook, chose the URL encoded type, and use the copied URL from your DeployHQ server settings as the URL, and save it. This means that every time commits are pushed to the repository, GitHub will send a payload to DeployHQ. DeployHQ, in turn, will check to see if it’s the correct branch, and if so, queue up and enact a deployment, since you have automatic deployments on.
Excellent! Let’s try it out. Head back to GitHub and update your
index.html file (or a different file if need be). Commit the change, and then take a look at your website.
DeployHQ has pushed it out there automatically without you even needing to do anything. Great stuff!
DeployHQ definitely isn’t the route to go for large organizations with their own complex needs that surpass this application. But for many, many web developers, services like DeployHQ will save time and energy. Match them up with an amazing host that provides proper SSH or SFTP connection ability, like our partner, SiteGround, and you’re ready to get deploying!