Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP deployment using Git. How can I make it more automated?

I am in charge of launching web projects and it takes a little too long currently from client sign off to final launch. It is on a server which I have root access to, but it runs Plesk so that the boss can setup VirtualHosts, which means there are many sites running on it.

Each project has its own git repository so currently I have the following setup.

On my staging server there is a clone of the repo and I have two bare repositories. One is on the forge (powered by Indefero) and the other is on the live server.

Each release of a project is tagged with todays date eg. git tag -a deployed-2011-04-20.

So on the staging server I execute something similar to git push --tags live master, which targets the bare repo on the live server.

Then over SSH on the live server I execute a short bash script which basically clones the repository from the live bare repo to the folder Apache will serve.

So if that all makes sense would you be able to recommend a tool or anything to make my life easier that follows that work flow or can be adapted?

It looks something like this:

Forge (authoritative source)
  ^
  |
  v
Staging/development server
  |
  v
Live server bare repo
  |
  v
Releases folder (symlinked to htdocs)
like image 561
Treffynnon Avatar asked Apr 20 '11 10:04

Treffynnon


People also ask

Can git be used for deployment?

Git is a very popular version control system used to implement development workflows. The Cloudways Platform allows you to deploy code to your application from your git repositories.


1 Answers

One solution that comes to mind is to add some post-receive hook on the live server bare repo in order to detect any deployed-2011-xx-yy tag coming from the staging repo, and to trigger the ssh script from there.

The other solution is to have a scheduler (like Hudson mention in pderaaij's answer, in order to:

  • monitor the stating repo and, on the right tag, trigger the push on the live server
  • monitor the live bare repo, and trigger the ssh script.

The second solution has the advantage to keep a trace of all release instances in an Hudson job report, each time said job detect the right tags and execute the release process.

like image 67
VonC Avatar answered Oct 23 '22 11:10

VonC