Skip to content

Instantly share code, notes, and snippets.

@firdoussross
Created April 6, 2020 06:31
Show Gist options
  • Save firdoussross/5d557646a87faa734694f113eae014d0 to your computer and use it in GitHub Desktop.
Save firdoussross/5d557646a87faa734694f113eae014d0 to your computer and use it in GitHub Desktop.
#!/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