D
D
Denis2011-06-23 16:39:02
git
Denis, 2011-06-23 16:39:02

Git deploy. Many developers versus one site with an admin panel

Hello. How do you deploy code from git? For example, there is a website in the git. A development team is working on this site. They all edit the code and send commits. Naturally, you need to be able to quickly and easily deploy a fresh version of the site on a (test) server.

Google on request git deploy gives me heaps of soulful articles about how easy and fun it is to put a site in a repository. It works if I'm the only developer. But what if we are a team?

When you try to do a git pull on the repository that contains the site, there are occasional permission issues. Since the repository is initialized by another user. Yes, and it's not pretty.
You can also create a separate user to pull changes to the repository. This solves the first problem, but does not solve a more significant one: when a certain file is uploaded through the admin panel, git pull will no longer work. You will need to push changes to the repository, and this is not always appropriate. Adding a directory with them to the exceptions will not help here - a file that already exists on the server can change through the admin panel.

How to be?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Exorcist, 2011-06-23
@Exorcist

For such purposes, you can and should use capistrano or something similar.

B
b0beR, 2011-06-24
@b0beR

I think the most convenient way is to use post-receive hooks in the central git repository (if there is one), or (if the project is hosted on github) use the post-receive url. At the same time, the deployment should include changes uploaded to one specific git branch (for the test version, this is most often the develop branch).
Again, if several people work on the site, there are no problems, since everyone first merges their changes to develop, after which they push the develop branches to the central repository.
Files that are changed from the admin should not be in the repository (it is logical to add them to .gitignore) If it is supposed that the original versions of these files should be in the repository, and then they can be edited from the admin (not a good practice), then it is more logical instead of the translation.xml file, for example, it will add the translation.tpl.xml file to the repository, and already in the deployment script itself (which is called from the hook), copy this file to the real translation.xml. If it was changed from the admin panel, then this is your problem, how to handle such conflicts. In a well-designed system, this should not be the case.
In general, it is very convenient to combine such a deployment system with the use of git flow. Then only code that is ready for testing will get into the develop branch (and, accordingly, immediately put to the test), and only production-ready code from the develop branch will be merged into master (if everything is done correctly, then from master you can automatically upload it to release , the main thing is that no one except the project manager pushes there)
PS If interested, I can write an article about using git flow in conjunction with the post-receive github URL to upload a test version.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question