Skip to content

Instantly share code, notes, and snippets.

@abelcallejo
Created November 27, 2018 02:35
Show Gist options
  • Save abelcallejo/df1f910315df31bc1e343008d36b9fb7 to your computer and use it in GitHub Desktop.
Save abelcallejo/df1f910315df31bc1e343008d36b9fb7 to your computer and use it in GitHub Desktop.
Git hook post-receive template
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
WORKTREE=/var/www/html/app/
git --work-tree=$WORKTREE checkout -f $branch
echo "Changes were successfully pushed to staging server at location $WORKTREE"
find $WORKTREE -iname "*.php" | xargs chmod 665
find $WORKTREE* -type d | xargs chmod 775
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment