Created
April 4, 2019 09:07
-
-
Save kovalbogdan95/cc9c05f347198496e90005d4f40e5dbd to your computer and use it in GitHub Desktop.
GitLab CI auto delpoy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| image: rastasheep/ubuntu-sshd:18.04 | |
| stages: | |
| - deploy | |
| deploy_prod: | |
| stage: deploy | |
| before_script: | |
| - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' | |
| - mkdir -p ~/.ssh | |
| - chmod 700 ~/.ssh | |
| - ssh-keyscan host.com >> ~/.ssh/known_hosts | |
| - chmod 644 ~/.ssh/known_hosts | |
| - eval $(ssh-agent -s) | |
| - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null | |
| script: | |
| - echo "Deploy to production server" | |
| - ssh -p22 [email protected] " | |
| cd /home/user/project && | |
| git pull && | |
| npm install && | |
| npm run prod" | |
| only: | |
| - master |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment