Skip to content

Instantly share code, notes, and snippets.

@warmansuganda
Created September 23, 2020 07:59
Show Gist options
  • Save warmansuganda/d2725c3ff60a0902f338e01f6e153ada to your computer and use it in GitHub Desktop.
Save warmansuganda/d2725c3ff60a0902f338e01f6e153ada to your computer and use it in GitHub Desktop.
NOTE : Move the following lines to the top of .bashrc if yarn, npm or node these command not found
#!/bin/bash
TARGET="/home/server/apps/pit-service"
GIT_DIR="/home/server/repos/pit-service.git"
BRANCH="master"
while read oldrev newrev ref
do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ];
then
echo "Ref $ref received. Deploying ${BRANCH} branch to production..."
git --work-tree=$TARGET --git-dir=$GIT_DIR checkout -f $BRANCH
cd $TARGET
ls -l
node -v
echo "Deployment Successfully..."
else
echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment