A
A
Alexander2019-04-03 11:27:15
git
Alexander, 2019-04-03 11:27:15

How to make the easiest deployment in GitLab?

Good day.
How best to organize the most minimal deployment to the server in GitLab. Let's say a simple HTML page. After merging to master and a successful pipeline to the prod server, checkout and pull.
From the solutions I found the following config for .gitlab-ci.yml :

deploy-master:
    stage: deploy
        script:
            - ssh [email protected] "
                cd /var/www/ &&
                git checkout . &&
                git checkout master &&
                git pull
            "
        environment:
            name: production

        only:
            - master

I wanted to discuss how this is the "correct" solution. And how would you do it.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Fedorov, 2019-04-03
@Minifets

And how would you do it.

I would put Deployer , it already has tasks:
- GIT
- NPM / Composer dependencies
- clearing the cache and that's all
- releases (in case of an error, do not roll the release and roll back migrations)
- setting rights and other things, if necessary
- if there are tests - running them, also phpstan and
. In Gitlab CI, in your case, I would call something like this:
deploy-master:
    stage: deploy
        script: dep --file=deploy/deploy.php -vvv deploy prod

Where:
- folders with releases are created
- the current release is linked to the last successful
one - when a new one is rolled out -- a folder with the release is created and on everything is put in it, if it is successful - the link is thrown to it, if not - everything remains as it is, you just need to take into account the work
with migrations master git and relink the release

A
abubekovdd, 2019-05-13
@abubekovdd

Another example of a config for deploying a php site, there is a config using rsync https://coderun.ru/blog/deplojj-php-sajjta-iz-gitl...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question