-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.sh
executable file
·71 lines (57 loc) · 1.39 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
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
set -e
# Change this
GIT_REMOTE_URL='ssh://github.com/laravel/laravel.git'
BASE_DIR=/app
TAG=$1
HTTP_DIR=$BASE_DIR/www
RELEASE_DIR=$BASE_DIR/releases/$TAG
# Symlink the release
function move_symlink {
mkdir -p $HTTP_DIR
rm -Rf $HTTP_DIR
ln -sf $RELEASE_DIR $HTTP_DIR
}
# The artisan commands
function artisan {
# Run database migrations
php artisan migrate --no-interaction --force
# Run optimization commands for Laravel
php artisan optimize
php artisan cache:clear
php artisan route:cache
php artisan view:clear
php artisan config:cache
}
read -p "Move release to $TAG? " -n 1 -r
echo # move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
if [[ -d $RELEASE_DIR ]]
then
cd $RELEASE_DIR
# Do artisan stuff
artisan
# Move symlink to release
move_symlink
else
# Create folder structure for releases if necessary
mkdir -p $RELEASE_DIR
cd $RELEASE_DIR
# Fetch the release files from git as a tar archive and unzip
git archive \
--remote=$GIT_REMOTE_URL \
--format=tar \
$TAG \
| tar xf -
# Install laravel dependencies with composer
composer install -o --no-interaction --no-dev
# Create symlinks to `shared`
ln -sf $BASE_DIR/shared/.env ./
rm -rf storage && ln -sf $BASE_DIR/shared/storage ./
# Do artisan stuff
artisan
# Move symlink to release
move_symlink
fi
fi