I try to upload files automatically to a remote server with SSH after pushing to staging branch.
I have the folling GitLab CI command in my .gitlab-ci.yml:
stages:
- deploy
deploy_staging:
stage: deploy
image: tetraweb/php:7.1
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- mkdir -p ~/.ssh
- eval $(ssh-agent -s)
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
- ssh-add <(echo "$DD_PRIVATE_KEY")
- apt-get install rsync
script:
- ssh -p22 ssh-xxxx@xxxxx.com "mkdir -p /website.com/_tmp"
- rsync -rav -e ssh --exclude='.git/' --exclude='.gitlab-ci.yml' --delete-excluded ./ ssh-xxxx@xxxxx.com:/xxx.com/_tmp
- ssh -p22 ssh-xxxx@xxxxx.com "mv /website.com/yyy/ /website.com/_old && mv /website.com/_tmp /website.com/yyy/"
- ssh -p22 ssh-xxxx@xxxxx.com "rm -rf /website.com/_old"
only:
- staging
The GitLab Job says Job succeeded
… but the files were not uploaded…in fact nothing happens… but I get no error message or warnings…
Is there an error in my CI file?