Automate php deployment on multiple servers with git hooks

Recently, we began to study GIT in order to allow our developers to work from anywhere and, secondly, to automate the overall deployment process.

We have a central test server on which we host all applications / sites for testing and / or demonstration purposes, and as soon as development and testing is completed, we move the application to the appropriate servers.

Whatever I install using GIT, it looks like this: 1. Create a bare repo on a test server
2. Get a local clone for each participating developer, the developers will be redirected to the remote (test server) dev branch 3. Someone will merge all changes from the dev branch to the master branch and push it to the remote
4. On the test server (bare repo) there is a post-receive hook that checks the main branch for the public_html folder (using GIT_WORKING_DIR and check -f).

At the moment, everything is working fine, and I can see the merge on the main branch on the hosted pages (on the test server, of course). Now my questions ... 1. Am I doing it right?
2. I assume that the installed post-reception that I installed also performs on the push-dev branch. How to avoid this? 3. How can I send this content to my live server? Since I have several projects with a large code base, checking everything on a test server, and then sending it live, looks good.

I heard about CI servers, but as far as I know, they check locally and download everything to live using "rsync" (I don’t know if it just synchronizes changes or downloads everything) or such tools. I just want to avoid this whole part and leave the option open for rollback if something goes wrong. I am fine with setting up GIT on live servers.

+6
source share
1 answer

As for deployment, as shown in Deploying with rsync (or svn, git, cvs) and ignoring inconsistent state during deployment? ", deploying (even everything) in a separate directory and a symlink instance of prod to this directory is a good way to avoid inconsistencies during deployment and to facilitate rollback (a symbolic link to the previous live directory) in case of problems.

+7
source

All Articles