image: owncloudci/php:7.2

stages:
    - deploy-homologacao
    - deploy-producao

Deploy Homologacao:
    cache: {}
    stage: deploy-homologacao
    before_script:
        - apt-get update -qq && apt-get install -y -qq lftp zip unzip
        - find -type l -exec bash -c 'ln -f "$(readlink -m "$0")" "$0"' {} \;
    script:
        - lftp -e "set ftp:ssl-allow no; mirror -Rnv ./ ./sandbox.api.pixerama.com.br/font --ignore-time --parallel=20 --exclude-glob .git* --exclude-glob *.pem --exclude .git/ --exclude node_modules/ exit;" -u $DEV_USERNAME,$DEV_PASSWORD $DEV_HOST
    after_script:
        - php artisan migrate
    only:
        - homologacao

Deploy Producao:
    cache: {}
    stage: deploy-producao
    before_script:
        - apt-get update -qq && apt-get install -y -qq lftp zip unzip
        - find -type l -exec bash -c 'ln -f "$(readlink -m "$0")" "$0"' {} \;
    script:
        - lftp -e "set ftp:ssl-allow no; mirror -Rnv ./ ./public_html/font --ignore-time --parallel=20 --exclude-glob .git* --exclude-glob *.pem --exclude .git/ --exclude node_modules/ exit;" -u $PROD_USERNAME,$PROD_PASSWORD $PROD_HOST
    after_script:
        - php artisan migrate
    only:
        - master
