forked from saproto/saproto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
59 lines (45 loc) · 1.35 KB
/
deploy.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# First verify the checksum between uploaded and live code to see if deployment is necessary.
echo "Verifying checksum..."
CURRENT_CHECKSUM=$(cat live/checksum.txt)
if [ $? -ne 0 ]; then
echo "No current checksum found. Assuming deployment is necessary."
CURRENT_CHECKSUM="NoCurrentChecksum"
fi
NEW_CHECKSUM=$(cat uploads/checksum.txt)
if [ $? -ne 0 ]; then
echo "Can't find new checksum. Should be there though. Exiting."
exit 1
fi
if [ "$CURRENT_CHECKSUM" == "$NEW_CHECKSUM" ]; then
echo "Checksums are identical, no deployment necessary."
exit 0
fi
# Clean-up
echo "Removing old build..."
rm -rf previous_build
# Prepare new build
echo "Unzipping new build..."
unzip -q uploads/build.zip -d new_build
echo "Shuffling files..."
cp uploads/checksum.txt new_build
cp environment/.env new_build
echo "Symlinking storage..."
ln -s /actual/path \
/symlinked/path
# Setup new build
echo "Bringing down builds..."
(cd new_build && php artisan down)
(cd live && php artisan down)
echo "Rotating builds..."
mv live previous_build
mv new_build live
echo "Migrating database..."
(cd live && php artisan migrate --force)
echo "Syncing permissions and roles..."
(cd live && php artisan 'proto:syncroles')
echo "clear laravel config"
(cd live && php artisan 'config:clear')
echo "Bringing up new live build..."
(cd live && php artisan up)
echo "Done!"