Last active
May 17, 2019 17:24
-
-
Save yumyo/9d9c80c061e6bf129f6a62edf463da99 to your computer and use it in GitHub Desktop.
WP Dev/Test/Live ENV post-receive hook #devops
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
# The PROD directory | |
PROD="/var/www/main.domain/" | |
# The TEST directory | |
TEST="/var/www/test.domain/" | |
# The DEV directory | |
DEV="/var/www/dev.domain/" | |
# A temporary directory for deployment | |
TEMP="/home/[server_user]/temp-deploy/" | |
# The Git repo | |
REPO="/home/[server_user]/git-domain-bare/" | |
while read oldrev newrev ref | |
do | |
# if deplying the master branch | |
if [[ $ref =~ .*/master$ ]]; | |
then | |
echo "Master ref received. Cleaning Production..." | |
rm -rf $PROD/wp/ && rm -rf $PROD/content/languages/ && rm -rf $PROD/content/themes/ && rm -rf $PROD/content/mu-plugins/ && rm -rf $PROD/plugins/ && rm -rf $PROD/vendor/ | |
echo "Deploying Master branch to Production..." | |
git --work-tree=$PROD --git-dir=$REPO checkout -f master | |
fi | |
# if deplying the test branch | |
if [[ $ref =~ .*/test$ ]]; | |
then | |
echo "Test ref received. Cleaning Test..." | |
rm -rf $TEST/wp/ && rm -rf $TEST/content/languages/ && rm -rf $TEST/content/themes/ && rm -rf $TEST/content/mu-plugins/ && rm -rf $TEST/plugins/ && rm -rf $TEST/vendor/ | |
echo "Deploying Test branch to Test..." | |
git --work-tree=$TEST --git-dir=$REPO checkout -f test | |
fi | |
# if deplying the develop branch | |
if [[ $ref =~ .*/develop$ ]]; | |
then | |
echo "Develop ref received. Cleaning Develop..." | |
rm -rf $DEV/wp/ && rm -rf $DEV/content/themes/ && rm -rf $DEV/content/languages/ && rm -rf $DEV/content/mu-plugins/ && rm -rf $DEV/plugins/ && rm -rf $DEV/vendor/ | |
echo "Deploying Develop branch to Dev..." | |
git --work-tree=$DEV --git-dir=$REPO checkout -f develop | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment