Created
April 6, 2020 06:31
-
-
Save firdoussross/5d557646a87faa734694f113eae014d0 to your computer and use it in GitHub Desktop.
This file contains 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 | |
DEPLOY_DIR=/var/www/public_html | |
# Get the version from package.json | |
PACKAGE_VERSION=$(grep version ../package.json \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[:space:]') | |
echo "Deploying MyApp v$PACKAGE_VERSION (staging)..." | |
cd .. | |
echo "Intalling NPM packages..." | |
npm install --loglevel=error | |
echo "Building MyApp v$PACKAGE_VERSION (staging)..." | |
npm run build:prod | |
echo "Clearing $DEPLOY_DIR..." | |
sudo rm -r ${DEPLOY_DIR:?}/* | |
echo "Moving resources to ${DEPLOY_DIR:?}/..." | |
sudo mv ./dist/my-app/* ${DEPLOY_DIR:?}/ | |
echo "Updating permissions of $DEPLOY_DIR..." | |
sudo chown -R www-data:www-data ${DEPLOY_DIR:?} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment