Skip to content

Commit

Permalink
Create production deployment script.
Browse files Browse the repository at this point in the history
  • Loading branch information
L-Eugene committed Nov 14, 2018
1 parent 248210d commit 4191110
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ deploy:
- /bin/bash ./deploy/development.sh
on:
branch: master
rvm: '2.4'
rvm: '2.4'
- provoder: script
skip_cleanup: false
script:
- /bin/bash ./deploy/production.sh
on:
tags: true
branch: master
rvm: '2.3'
37 changes: 37 additions & 0 deletions deploy/production.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash

cat >/tmp/upgrade_script.sh <<EOF
# UPDATE SOURCE
echo "Updating source from Git"
cd $VK_INFORMER_PROD_PATH
git pull
# UPDATE GEMSET
echo "Updating bundle"
cd $VK_INFORMER_PROD_BOTSERVER_PATH
$VK_INFORMER_PROD_RVM/bundle install --without test
$VK_INFORMER_PROD_RVM/bundle update
# UPDATE DATABASE
cd $VK_INFORMER_PROD_BOTSERVER_PATH/app
$VK_INFORMER_PROD_RVM/rake vk:db:migrate
# RESTART BOTSERVER
echo "Restarting server"
sudo service $BOTSERVER_SERVICE_PROD restart
EOF

# Remove old version of upgrade script
ssh $DEPLOY_USER@$DEPLOY_SERVER '[ -f upgrade_script.sh ] && rm upgrade_script.sh'

# Copy upgrade script to server
scp /tmp/upgrade_script.sh $DEPLOY_USER@$DEPLOY_SERVER:upgrade_script.sh

# Execute upgrade script
ssh $DEPLOY_USER@$DEPLOY_SERVER /bin/bash ./upgrade_script.sh
DEPLOY_STATUS=$?

# Remove upgrade script from server
ssh $DEPLOY_USER@$DEPLOY_SERVER '[ -f upgrade_script.sh ] && rm upgrade_script.sh'

exit $DEPLOY_STATUS

0 comments on commit 4191110

Please sign in to comment.