Skip to content

Instantly share code, notes, and snippets.

@edwardoboh
Created July 18, 2022 09:10
Show Gist options
  • Save edwardoboh/b314fc0c52d460868f0ab8b574484bb4 to your computer and use it in GitHub Desktop.
Save edwardoboh/b314fc0c52d460868f0ab8b574484bb4 to your computer and use it in GitHub Desktop.
cPanel Git Post Receive Hook
#!/bin/bash
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "master" == "$branch" ]; then
git --work-tree=./path/under/root/dir/live-site/ checkout -f $branch
echo 'Changes pushed live.'
fi
if [ "dev" == "$branch" ]; then
git --work-tree=./path/under/root/dir/dev-site/ checkout -f $branch
echo 'Changes pushed to dev.'
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment