Created
September 24, 2019 21:43
-
-
Save e200/6c31737c53378abceeeedec6508fb2b8 to your computer and use it in GitHub Desktop.
Git hook
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 | |
DEST_FOLDER='/var/www/example' | |
SOURCE_REPO='~/projects/app.git' | |
git --work-tree=$DEST_FOLDER --git-dir=$SOURCE_REPO checkout -f | |
changed_files="$(git diff-tree -r --name-only --no-commit-id HEAD)" | |
cd $DEST_FOLDER | |
echo $changed_files | grep --quiet "package.json" | |
if [ $? -eq 0 ] | |
then | |
npm i | |
fi | |
npm run build | |
pm2 restart web |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment