-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy-rsync
executable file
·75 lines (54 loc) · 1.68 KB
/
deploy-rsync
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/bin/bash
# Exit if any command fails
set -e
# Variables
COMMIT=${1}
REMOTE=${2}
TIMESTAMP=`date`
echo '-----------------------------'
echo 'Welcome to Pusher, beginning build.'
echo '-----------------------------'
# Directory we're in
echo "In directory `pwd`"
echo "Deploying commit: $COMMIT"
# Move to repo dir
cd repo
# Update our branches from origin
git fetch origin
# Checkout the branch that is going to be deployed
git checkout $COMMIT
# rsync to move to deploy directory
rm -rf ../deploy/wp-content
# Rsync over the repo
rsync -az --exclude .git --exclude .gitignore ./ ../deploy/wp-content/
# Copy the ENV file if it exists
cd ../
if [ -f .env.php ]; then
cp .env.php deploy/wp-content/mu-plugins/app/
fi
# Copy the auth.json file if it exists
if [ -f auth.json ]; then
cp auth.json deploy/wp-content/auth.json
fi
# move to deploy folder
cd deploy/wp-content
cp ~/scripts/.gitignore-master .gitignore
# Combine excludes to allow custom exclusions
touch .excludes
cat ~/scripts/rsync-excludes.txt .excludes > rsync-excludes.txt
# Build steps (composer, npm, gulp, etc)
if [ -f composer.lock ]; then
echo '-----------------------------'
echo 'Running Composer'
echo '-----------------------------'
composer install -o --prefer-dist --no-progress --no-dev
fi
#git add .
#git commit -am "Build release $COMMIT [$TIMESTAMP]"
echo '-----------------------------'
echo "Beginning file transfer to server: $2 via rsync"
echo '-----------------------------'
rsync -zhrlD "$(pwd -P)/" $2 --delete --exclude-from 'rsync-excludes.txt'
echo '-----------------------------'
echo 'File transfer completed (see above for any issues)'
echo '-----------------------------'