Created
December 7, 2017 00:45
-
-
Save silveur/6d34651b1f5efbef83971cf59c9c5917 to your computer and use it in GitHub Desktop.
Deploy script from post-receive with nvm
This file contains hidden or 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 | |
set -u | |
set -e | |
export NVM_DIR="$HOME/.nvm" | |
. "$NVM_DIR/nvm.sh" | |
target_branch="master" | |
working_tree="" | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ -n "$branch" ] && [ "$target_branch" == "$branch" ]; then | |
GIT_WORK_TREE=$working_tree git checkout $target_branch -f | |
NOW=$(date +"%Y%m%d-%H%M") | |
git tag release_$NOW $target_branch | |
cd $working_tree && npm install && npm run build && forever restartall | |
echo " /===============================" | |
echo " | DEPLOYMENT COMPLETED" | |
echo " | Target branch: $target_branch" | |
echo " | Target folder: $working_tree" | |
echo " | Tag name : release_$NOW" | |
echo " \==============================" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment