4

Bit of a generalised "what do you think the best solution is" question, but I've read and I've read and I don't seem to find all the answers to all my questions.

I work at a small web agency with 3 devs (2 onsite 1 offsite) where we're still using FTP (style-1.css, style-2.css) working on sites hosted online at a preview url, we then download the finished work and re-upload it to it's live url. It's pretty old school and completely wrong by today's standards I know, so I've started to look at Git. I'd like to be able to use it to manage the deployment as well.

What I'd like to be able to do is this:

  • Dev works locally
  • Dev pushes to preview/staging on server (publicly accessible)
  • Client approves
  • Dev pushes preview to live / dev tells live to pull from preview

What I'd like to know is:

  • Can I set up the remote repo on the server to hold all the files we're working on, so we can point a url to these files to use as a preview/staging site? (ie why have I read that this should be a bare repo?)
  • What's the best way to set up the 'live' site in this scenario? Could someone please explain how I could set up a command (a hook?) to pull from the preview site into the live site when we deem it stable?

I've tried reading into work flows but I haven't found how to use this in a live publicly(client) accessible work flow

Thanks in advance!

Edit

I've received a suggestion to use GitHub and I'd rather not use it for this since we have our own dedicated server and I don't mind putting in the time to learn and set it up correctly. (I'll be using GitHub for personal work so I'm not knocking it as a service)

The title includes Gitolite because I had originally intended to ask how to set this up using gitolite but in the middle of writing it I figured I'd get the basics right and so edited it out, must have forgotten to remove it from the title. If anyone has any suggestions for this that include gitolite I'd be willing to give it a shot.

Thanks for the suggestions so far

Paul Tibbetts
  • 321
  • 3
  • 7
  • Here's an [article](http://www.exsyshost.com/clients/knowledgebase/142/Using-Gitolite-to-securely-deploy-a-website-with-version-control-based-on-the-GitHub-Flow.html) on the subject. You may not want to use all his code, but you can get a global picture and implement your own solution based on this. – Simon Boudrias Jan 24 '13 at 15:58
  • Thankyou Simon, that's a great article and will definitely help me. – Paul Tibbetts Jan 25 '13 at 15:22

3 Answers3

2

Note that:

Community
  • 1
  • 1
VonC
  • 1,042,979
  • 435
  • 3,649
  • 4,283
  • Thanks for the links Von. Is the workflow I've suggested a reasonable way to use Git? ie. making the development branch publicly viewable? Or am I getting the wrong end of the stick? - I know Git's for version control and not for deployment, but I'd like it to do both for us – Paul Tibbetts Jan 25 '13 at 15:31
  • @PaulTibbetts in term of deployment, I would avoid git on the production server (as mentioned in http://stackoverflow.com/a/8122183/6309), but otherwise, pushing to a bare repo and pulling from the target repo is a good way to achieve that. If visibility (as in "other can modify") is an issue, then yes, using gitolite is better. – VonC Jan 25 '13 at 16:10
  • Thanks VonC, you steered me away from making a mess of the server. I've gone with Beanstalk to manage the deployment. I'll hopefully get around to sorting it out without one day. – Paul Tibbetts Jan 29 '13 at 17:08
1

Answering my own question

Just wanted to provide an update with what I went with for others who are having the same problem as me.

In the end, to use git and manage deployment, I've gone with BeanStalk, however I have also considered using Capistrano and might even use them both together.

Thanks to Simon for the article, Makis for explaining what I'd be using hooks for and VonC for steering me away from messing up my server and making things more difficult for myself.

Community
  • 1
  • 1
Paul Tibbetts
  • 321
  • 3
  • 7
0

If you can spare a few dollars & want this hassle free I would set up a repo in GitHub. This would save a lot of hassle. It seems that GitHub costs are starting from $7/mo for private repos. There are many good things doing it like this, but the biggest one in your case is that the repos are readily available from anywhere without any setup.

The script you are asking for would simply only a) set the site to point to some "maintenance going on" page for the duration, b) pull changes from the GitHub repo and c) possibly restart services (MySql etc). I wouldn't completely automate this, but it wouldn't be too hard either.

I would use branches to manage what is preview and what is delivery-level. So the script would pull the head from the release branch.

Similarily, devs would push to GitHub using whatever branching strategy works best for you.

Makis
  • 11,130
  • 10
  • 58
  • 70
  • Thanks for the suggestion Makis, I like the ideas you've put forward but ultimately I'd like to be doing this without GitHub since we have our own server and I don't mind learning to do it self-hosted. I'm going to start using GitHub for personal work. Thanks. – Paul Tibbetts Jan 25 '13 at 15:28
  • In that case, have a look at Gitorious at http://www.gitorious.org. I have set up couple of installations with it. It's not as sophisticated as GitHub but still very usable. – Makis Jan 28 '13 at 09:19