Let's say you have Gitlab, with the
test.git repository. It has many branches, and two main ones are
qa . During the development process, the developers create their own branches that correspond to the tasks, then all this is merged through merge requests to the
dev branch. When you need to roll out a release, there is a need to deploy to the test server from the
qa branch, and when the test is successful, you need to deploy to production from the
Let's assume that the test server and the production server are on the same machine. At the moment, after all the changes from
qa have been pushed, after pushing, I go to the server and execute a command there, something like this:
git archive --remote=/git-data/repositories/root/test.git qa | tar -x -C /test-server/sites/test/
If everything is tested and everything is ok, the
qa branch is merged into
master , and I go to the server again and execute the following command:
git archive --remote=/git-data/repositories/root/test.git master | tar -x -C /prod-server/sites/test/
This is all stressful, and I want to automate this process. I would like to create some bash script (for example, just drive the same
git archive into it for a moment), which will be automatically launched after making changes to the
qa branch. For example, after pushing to
/home/testuser/deplloy-qa.sh will work, and after pushing to
/home/testuser/deplloy-master.sh will work. Or, it would be possible to execute such scripts not automatically when pushing, but from the Gitlab interface (which is more interesting, and in my opinion more convenient), there are such things as Builds / Runners – I don't know if they can be used to solve my task.
I would be grateful for the helpful answers, I would like to understand and see how the problem can be solved using my example, both in the first and second ways.
To solve the routine task of updating file versions on test or production sites described by you , services like Github have added the ability to create a WebHook that will knock on the specified address or script when the events you select, for example, when pushing to the develop or master branch, a regular php file will be called ( well, or depending on which programming language you will use) where the execution of the shell script with the data you need will be written. For example, I advise you to look at an old article that Google issues almost immediately for such a request. By the way, in the comments to that article, there is a link to a simpler version of the script . So there is nothing difficult in setting up autodeploy by repository events, you just have to search.