image: alpine:3.8
stages:
  - deploy
  - build

staging-en:
  stage: deploy
  before_script:
    #- apk add --no-cache lftp
    - apk add --no-cache openssh-client rsync sshpass
    - mkdir -p ~/.ssh
    - ssh-keyscan $EN_HOST > ~/.ssh/known_hosts
  script:
    - sshpass -p $EN_PASSWORD rsync -rz --exclude .git/ --exclude .idea/ --exclude cache/ --exclude .* --exclude log/ --exclude data/ --exclude docker/ --exclude wagabundotravel/ --stats --progress . $EN_USERNAME@$EN_HOST:~
    - sshpass -p $EN_PASSWORD ssh $EN_USERNAME@$EN_HOST cp apps/wagat/config/view.en.yml apps/wagat/config/view.yml
    - sshpass -p $EN_PASSWORD ssh $EN_USERNAME@$EN_HOST cp apps/wagat/config/routing.en.yml apps/wagat/config/routing.yml
    - sshpass -p $EN_PASSWORD ssh $EN_USERNAME@$EN_HOST sed -i -e 's/pl_PL/en_US/g' apps/wagat/config/settings.yml
    - sshpass -p $EN_PASSWORD ssh $EN_USERNAME@$EN_HOST rm -fr ~/cache/*
  only:
    - master
  environment:
    name: staging-en
    url: https://kamen.wagabundotravel.pl

staging-pl:
  stage: deploy
  before_script:
    #- apk add --no-cache lftp
    - apk add --no-cache openssh-client rsync sshpass
    - mkdir -p ~/.ssh
    - ssh-keyscan $PL_HOST > ~/.ssh/known_hosts
  script:
    #- lftp -e "mirror -vvv --exclude .git* --exclude ^\.idea.* -R . /; exit; " sftp://$PL_USERNAME:$PL_PASSWORD@$PL_HOST
    - sshpass -p $PL_PASSWORD rsync -rz --exclude .git/ --exclude .idea/ --exclude cache/ --exclude .* --exclude log/ --exclude data/ --exclude docker/ --exclude wagabundotravel/ --stats --progress . $PL_USERNAME@$PL_HOST:~
    - sshpass -p $PL_PASSWORD ssh $PL_USERNAME@$PL_HOST rm -fr ~/cache/*
  only:
    - master
  environment:
    name: staging-pl
    url: https://kampl.wagabundotravel.pl

