At 2020Social we’ve been building some really cool apps over the last few months. Working with multiple apps means that we need to keep track of what we’re up to, what changes we make etc. And since we iterate rapidly, we need to make sure that we know what bits of code we’re changing. So we use Github as a source code repository.
The first thing we did was set up 2020Social as an organization on Github — you can find us here. This has the major advantage of allowing us to set up teams of people working on a particular code. It also allows us to set up a team that comprises only of all the servers we have lying around.
So, the formal (and truly great) way to deploy to servers is using Capistrano. But it can seem like overkill at times, especially on our dev servers. So, we came up with a (hopefully elegant) solution. Of course, this only works if you’re comfortable with the *nix command line and have ssh access to your servers.
- Install git on webfaction in our home directory [instructions]
- Create an ssh key pair. To know more about ssh keys check this out.
ssh-keygen -t dsa "give your server a name"
- Create a user using the free plan on github.com, add the ssh key generated above
- Create a team on github in your organization — call it servers — and add the user you just created. Give this team only pull rights
- On your server, set up an application folder. On webfaction you need to use the web-based control panel.
- In the application folder, do the following
git remote add [repo_name] [repo_url]
git pull [repo_name] [branch_name]
That’s it. You can now merrily pull code on to your server from your github repo. And if you avoid uploading files, you’ll know for a fact that all the versions of code floating around are connected to each other, with a history you can track.