Skip to content

Instantly share code, notes, and snippets.

@kovalbogdan95
Created April 4, 2019 09:07
Show Gist options
  • Save kovalbogdan95/cc9c05f347198496e90005d4f40e5dbd to your computer and use it in GitHub Desktop.
Save kovalbogdan95/cc9c05f347198496e90005d4f40e5dbd to your computer and use it in GitHub Desktop.
GitLab CI auto delpoy
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