Created
December 13, 2016 09:43
-
-
Save seancheung/7ad04b2ab2e7e444d25e9ba1dbf4bed9 to your computer and use it in GitHub Desktop.
git post receive 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 | |
while read oldrev newrev refname | |
do | |
branch=$(git rev-parse --symbolic --abbrev-ref $refname) | |
if [ "master" == "$branch" ]; then | |
GIT_WORK_TREE=/path/to/website git checkout master -f | |
echo "password" | sudo -S chown -R git:www /path/to/website && sudo chmod -R 775 /path/to/website | |
cd /path/to/website/cache/folder | |
for DIR in `find . -mindepth 1 -maxdepth 1 -type d` | |
do | |
sudo rm -R -rf "$DIR" | |
done | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment