Skip to content

Instantly share code, notes, and snippets.

@pbzona
Last active November 19, 2017 06:35
Show Gist options
  • Save pbzona/1dbe378d345e52b00e5844a10c3ff451 to your computer and use it in GitHub Desktop.
Save pbzona/1dbe378d345e52b00e5844a10c3ff451 to your computer and use it in GitHub Desktop.
Post receive hook for deploying React apps to Linode
#!/bin/bash
TARGET="/var/www/react"
GIT_DIR="/var/www/react.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
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