Skip to content
This repository has been archived by the owner on Jul 9, 2019. It is now read-only.

Commit

Permalink
Revamp deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jant-eficode committed Oct 3, 2018
1 parent e5940d3 commit fdf901d
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ jobs:
node_js:
- '10'
before_script:
- openssl aes-256-cbc -K $encrypted_19f1f1d7001a_key -iv $encrypted_19f1f1d7001a_iv -in deploy_key.enc -out /tmp/deploy_key -d
script: bash .travis_deploy.sh
- openssl aes-256-cbc -K $encrypted_19f1f1d7001a_key -iv $encrypted_19f1f1d7001a_iv -in deploy/deploy_key.enc -out deploy/deploy_key -d
script: bash deploy.sh

notifications:
email: false
Expand Down
2 changes: 0 additions & 2 deletions .travis_deploy.sh

This file was deleted.

2 changes: 2 additions & 0 deletions deploy/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
chmod 600 deploy/deploy_key;
cat deploy/update_app.sh | ssh -oStrictHostKeyChecking=no -i deploy/deploy_key "$DEPLOY_USER@$DEPLOY_SERVER"
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "$DIR"
. venv/bin/activate
. ~/venv/bin/activate
gunicorn -w 4 --access-logfile - --error-logfile - sahkopiikki.wsgi
50 changes: 50 additions & 0 deletions deploy/update_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
. .bashrc
nvm use 10
APP_DIR=~/sahkopiikki
cd "$APP_DIR"

echo "# Starting deployment."
set -e # Fail the script on any errors.

echo "# Stashing local changes to tracked files."
git stash

echo "# Fetching remote."
git fetch --all

echo "# Checking out production."
git checkout production

echo "# Pulling latest changes."
git pull

echo "# Navigating to the frontend directory."
cd frontend

echo "# Installing Node.js dependencies."
npm ci

echo "# Building the frontend project."
npm run build

echo "# Setting new build as the active build."
rm -rf "$APP_DIR/frontend/dist"
mv "$APP_DIR/frontend/build" "$APP_DIR/frontend/dist"

echo "# Navigating to the backend directory."
cd ../backend

echo "# Activating virtualenv."
set +e # The activate script might return non-zero even on success
source venv/bin/activate
set -e

echo "# Installing pip requirements."
pip install -r requirements.txt

echo "# Restarting the backend service."
sudo systemctl restart sahkopiikki

set +e
echo "# Deployment done!"

0 comments on commit fdf901d

Please sign in to comment.