Last active
August 29, 2015 14:09
-
-
Save spiermar/f9a872865675cd060e45 to your computer and use it in GitHub Desktop.
git pre-receive deploy hook
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 | |
DEPLOY_DIR=/apps/myapp | |
SERVICE_NAME=myservice | |
NOW=$(date +"%Y%m%d%H%M%S") | |
mkdir -p $DEPLOY_DIR/releases/hotpush-$NOW && cat | tar -x -C $DEPLOY_DIR/releases/hotpush-$NOW | |
cp $DEPLOY_DIR/current/prod.env $DEPLOY_DIR/releases/hotpush-$NOW | |
(cd $DEPLOY_DIR/releases/hotpush-$NOW && npm install) | |
sudo chown -R node:deploy $DEPLOY_DIR/releases/hotpush-$NOW | |
sudo service $SERVICE_NAME stop | |
rm $DEPLOY_DIR/current | |
ln -s $DEPLOY_DIR/releases/hotpush-$NOW $DEPLOY_DIR/currenth | |
sudo chown node:deploy $DEPLOY_DIR/current | |
sudo service $SERVICE_NAME start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment