deploy_staging:
  stage: deploy
  image: tetraweb/php:7.0
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
    - eval $(ssh-agent -s)
    - ssh-add <(echo "$STAGING_PRIVATE_KEY")
    - mkdir -p ~/.ssh
    - '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'

  script:
    - rsync -rav -e "ssh -p 2222" --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded ./ keentech@198.38.91.53:~/dent
    - ssh -p 2222 keentech@198.38.91.53 "mv ~/dent.keentech.co ~/dent.keentech.co-old"
    - ssh -p 2222 keentech@198.38.91.53 "cp -fr ~/dent ~/dent.keentech.co" 
    - ssh -p 2222 keentech@198.38.91.53 "rm -rf ~/dent.keentech.co-old"
  only:
    - master
