Skip to content

Instantly share code, notes, and snippets.

@e200
Created September 24, 2019 21:43
Show Gist options
  • Save e200/6c31737c53378abceeeedec6508fb2b8 to your computer and use it in GitHub Desktop.
Save e200/6c31737c53378abceeeedec6508fb2b8 to your computer and use it in GitHub Desktop.
Git hook
#!/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