Guest User

Untitled

a guest
May 26th, 2020
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. image: ubuntu:18.04
  2.  
  3. before_script:
  4. ##
  5. ## Install ssh-agent if not already installed, it is required by Docker.
  6. ## (change apt-get to yum if you use an RPM-based image)
  7. ##
  8. - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client docker-compose -y )'
  9.  
  10. ##
  11. ## Run ssh-agent (inside the build environment)
  12. ##
  13. - eval $(ssh-agent -s)
  14.  
  15. ##
  16. ## Create the SSH directory and give it the right permissions
  17. ##
  18. - mkdir -p ~/.ssh
  19. - chmod 700 ~/.ssh
  20.  
  21. ##
  22. ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  23. ## We're using tr to fix line endings which makes ed25519 keys work
  24. ## without extra base64 encoding.
  25. ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  26. ##
  27. - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa
  28.  
  29. - chmod -R 600 ~/.ssh/
  30.  
  31. - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
  32.  
  33. deploy:
  34. type: deploy
  35. environment:
  36. name: VPS
  37. url: xxx.co.uk
  38. script:
  39. - ssh root@xxx.co.uk "cd /var/apps/trial-project && git checkout master && git pull origin master && ./deploy && exit"
  40. only:
  41. - master
Add Comment
Please, Sign In to add comment