Last active
April 16, 2019 10:12
-
-
Save VasylShevchenko/2f6d9c9af9c64e0687c1a9c13a099426 to your computer and use it in GitHub Desktop.
gitlab-ci
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
deploy: | |
image: ubuntu:latest | |
stage: deploy | |
only: | |
- master | |
before_script: | |
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )' | |
- apt-get install -y rsync | |
- mkdir -p ~/.ssh | |
- chmod 700 ~/.ssh | |
- eval $(ssh-agent -s) | |
- ssh-add <(echo "$SSH_PRIVATE_KEY") | |
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config' | |
- echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts | |
script: | |
- echo "Deploy" | |
- ssh -o StrictHostKeyChecking=no [email protected] 'cd /home/deployer/apps/comparison_appnext && sh deploy.sh && exit' | |
- echo "Deploy finished" |
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
#!/bin/bash | |
echo "Deploy script start (deploy.sh)" | |
echo "" | |
echo "Git fetch ($ git fetch --all && git reset --hard origin/master)" | |
git fetch --all | |
git reset --hard origin/master | |
echo "" | |
echo "bundle install" | |
/home/deployer/.rvm/wrappers/ruby-2.5.2/bundle install | |
echo "" | |
echo "rake db:migrate RACK_ENV=production" | |
/home/deployer/.rvm/wrappers/ruby-2.5.2/rake db:migrate RACK_ENV=production | |
echo "" | |
echo "Restart Unicorn ($ sudo /usr/sbin/service unicorn stop && sudo /usr/sbin/service unicorn start && sudo /usr/sbin/service unicorn status )" | |
sudo /usr/sbin/service unicorn stop | |
sudo /usr/sbin/service unicorn start | |
sudo /usr/sbin/service unicorn status | |
echo "" | |
echo "Restart Nginx ($ sudo /usr/sbin/service nginx restart && sudo /usr/sbin/service nginx status)" | |
sudo /usr/sbin/service nginx restart | |
sudo /usr/sbin/service nginx status | |
echo "Deploy script finish (deploy.sh)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment