-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpost-receive.sh
35 lines (26 loc) · 1.01 KB
/
post-receive.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/bin/bash
DOMAIN="yourdomain.com"
THEME="theme_name"
DEPLOY_DIR="/opt/easyengine/sites/${DOMAIN}/app/htdocs/wp-content/themes/${THEME}"
WEB_URL="https://${DOMAIN}"
DEV_DOMAIN='dev.yourdomain.com'
DEV_DIR="/opt/easyengine/sites/${DEV_DOMAIN}/app/htdocs/wp-content/themes/${THEME}"
DEV_URL="https://${DEV_DOMAIN}"
while read oldrev newrev ref
do
BRANCH=`echo $ref | cut -d/ -f3`
if [ "master" == "$BRANCH" ]; then
sudo git --work-tree=$DEPLOY_DIR checkout -f $BRANCH
sudo ee site clean $DOMAIN
sudo chown -R www-data:www-data $DEPLOY_DIR
echo "You've just deployed your ${BRANCH} branch to ${WEB_URL}"
echo "Open ${WEB_URL} to check your changed"
fi
if [ "dev" == "$BRANCH" ]; then
sudo git --work-tree=$DEV_DIR checkout -f $BRANCH
sudo chown -R www-data:www-data $DEV_DIR
echo "You've just deployed your ${BRANCH} branch to ${DEV_DOMAIN}"
echo "Open ${DEV_URL} to check your changed"
fi
sudo chown -R git:git /home/git/$DOMAIN
done