Answer the question
In order to leave comments, you need to log in
How to auto-deploy when pushing to a specific branch in a repository?
Let's say we have Gitlab, with the test.git repository . It has many branches, and the two main ones are master and qa . During the development process, developers create their own branches that correspond to the tasks, then all this is merged through merge requests into the dev branch . When you need to roll out a release, there is a need to deploy to a test server from the qa branch , and when the test is successful, you need to deploy to production from the master branch .
Let's assume that the test server and the production server are on the same machine. At the moment, after all the changes from dev to qa have been merged, 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/
git archive --remote=/git-data/repositories/root/test.git master | tar -x -C /prod-server/sites/test/
Answer the question
In order to leave comments, you need to log in
You need to make a post-receive hook, git passes arguments to it in stdin in this order: oldrev newrev ref. Here is an example:
#!/bin/bash
while read oldrev newrev ref; do
branch=${ref##*/}
if ; then
# вот он, ваш мастер
elif ; then
# qa
fi
done
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question