Using Github with Webfaction (or AWS, or pretty much any other server)

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.

We use Webfaction as a dev server before moving our apps over to Amazon Web Services. And we’ve figured out how to use Git to tie it all together.

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.

  1. Install git on webfaction in our home directory [instructions]
  2. Create an ssh key pair. To know more about ssh keys check this out.


    cd ~/.ssh
    ssh-keygen -t dsa "give your server a name"

  3. Create a user using the free plan on github.com, add the ssh key generated above
  4. Create a team on github in your organization — call it servers — and add the user you just created. Give this team only pull rights
  5. On your server, set up an application folder. On webfaction you need to use the web-based control panel.
  6. In the application folder, do the following

    git init
    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.

Leave a Reply

Your email address will not be published. Required fields are marked *