diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6923c81637ba4f15675c2bbc6b3f2da1e1df5ae8..99501e98ce0fffde24a66475ea493cad051d559e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -46,19 +46,32 @@ deploy to stage: - mkdir -p ~/.ssh - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config script: - - ls site/ - - echo $CI_BUILD_REF_NAME - - ssh root@"$SSH_HOST_STAGE" uptime - - rsync -av --delete site/ root@"$SSH_HOST_STAGE":/tmp/docs/$CI_BUILD_REF_NAME/ - #- dpl --provider=s3 --bucket=$S3_BUCKET_NAME + #- ls site/ + #- echo $CI_BUILD_REF_NAME + #- ssh root@"$SSH_HOST_STAGE" uptime + - rsync -av --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/devel/$CI_BUILD_REF_NAME/ deploy to production: environment: production stage: deploy image: ruby:latest + before_script: + # install ssh-agent + - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' + - 'which rsync || ( apt-get update -y && apt-get install rsync -y )' + # run ssh-agent + - eval $(ssh-agent -s) + # add ssh key stored in SSH_PRIVATE_KEY variable to the agent store + - ssh-add <(echo "$SSH_PRIVATE_KEY") + # disable host key checking (NOTE: makes you susceptible to man-in-the-middle attacks) + # WARNING: use only in docker container, if you use it with shell you will overwrite your user's ssh config + - mkdir -p ~/.ssh + - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config script: - - gem install dpl - #- dpl --provider=s3 --bucket=$S3_BUCKET_NAME + #- ls site/ + #- echo $CI_BUILD_REF_NAME + #- ssh root@"$SSH_HOST_STAGE" uptime + - rsync -av --delete site/ root@"$SSH_HOST_STAGE":/srv/docs.it4i.cz/site/ only: - master when: manual