T
T
tester_toster2018-04-02 09:18:32
git
tester_toster, 2018-04-02 09:18:32

How to implement auto-deploy with bitbooket?

Good afternoon.
I have never used the git before, I improved my knowledge on it at the weekend - I liked it. I also heard about auto-deployment of certain git branches for the test and main server when their branches change.
As implemented now:
Created a repository on bitbucket
Generated an rsa key on the server, registered it in the settings.
The site got three subdomains:
dev.xxxx - test server
www.xxx - main
git.xxx - for webhook bitbucket
Above the domain root for webhook, I created a git folder, cloned the bitbucket repository there.
Registered webhook bitbucket at dev.xxx/deploy.php?key=xxxx The result was
a file with something like this:

// проверка на наличие обновлений в ветке, если есть - продолжаем, иначе выход
// обновляем репозиторий
system("cd ".$git."; git checkout dev; git pull;");
// удаляем папку с основными данными
system('rm -rf '.$dev.'/app'); 
// удаляем папку vendor
system('rm -rf '.$dev.'/vendor'); 
// копирум новые данне
system('rsync -av --exclude=".git" '.$git.'/ '.$dev);
// Запускаем composer
system('cd '.$dev.'; export COMPOSER_HOME="'.$composerTempDir.'"; '.$php.' '.$composer.'  install  2>&1');

How to implement correctly?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey, 2018-04-02
@azovl

Jenkins can do this. https://www.youtube.com/watch?v=nNaR5Q_pIa4

D
dmitriy, 2018-04-02
@dmitriylanets

You've gone the wrong way.
Look towards piplines, rsync

B
balankt, 2018-04-03
@balankt

Here is a link to the script repository that I used to deploy my projects
https://bitbucket.org/lilliputten/automatic-bitbuc...
It generally describes how to do it right

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question