-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathEnvoy.blade.php
120 lines (99 loc) · 2.56 KB
/
Envoy.blade.php
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{{--@formatter:off--}}
@servers(['production' => ['hamburg.hyn.me']])
@setup
require_once __DIR__ . '/vendor/autoload.php';
(new \Dotenv\Dotenv(__DIR__, '.env'))->load();
$keep = 3;
$remove = $keep +1;
$repository = 'git@github.com:hyn/laravel-tenancy.com.git';
$now = new DateTime();
$path = '/domains/laravel-tenancy.com/';
$releases = $path . 'releases/';
$release = $releases . $now->format('Ymd-His');
$current = $path . 'current';
$shared = $path . 'shared';
$webUser = 'luceos';
if (empty($branch)) {
$branch = 'master';
}
$at = "-b $branch";
if (!empty($tag)) {
$at = "-b $tag";
}
$gitCloneCommand = "git clone --depth 1 $at --recursive -q --reference $release --dissociate $repository $release";
@endsetup
@story('deploy', ['parallel' => true])
directory
clone
shared
composer
laravel
permissions
cleanup
symlink
graceful
@endstory
@task('directory')
if [ ! -d "{{ $path }}" ]; then
mkdir -p {{ $path }};
fi
if [ ! -d "{{ $shared }}" ]; then
mkdir -p {{ $shared }};
fi
if [ ! -d "{{ $release }}" ]; then
mkdir -p {{ $release }};
fi
@endtask
@task('permissions')
cd {{ $release }};
sudo chown -R {{ $webUser }}: storage;
sudo chown -R {{ $webUser }}: bootstrap/cache;
@endtask
@task('clone')
cd {{ $release }};
echo {{ $gitCloneCommand }};
{{ $gitCloneCommand }};
@endtask
@task('shared')
if [ ! -d "{{ $shared }}/storage" ]; then
mv {{ $release }}/storage {{ $shared }}/storage;
fi
rm -rf {{ $release }}/storage;
ln -s {{ $shared }}/storage {{ $release }}/storage;
if [ ! -f "{{ $shared }}/.env" ]; then
touch {{ $shared }}/.env;
fi
ln -s {{ $shared }}/.env {{ $release }}/.env;
@endtask
@task('composer')
cd {{ $release }};
composer install --no-dev --no-progress -o -n --prefer-dist -q;
@endtask
@task('laravel')
cd {{ $release }};
php artisan cache:clear;
php artisan queue:restart;
php artisan config:cache;
php artisan storage:link;
php artisan optimize;
@endtask
@task('symlink')
if [ -L "{{ $current }}" ]; then
rm {{ $current }}
fi
ln -s {{ $release }} {{ $current }};
@endtask
@task('cleanup')
cd {{ $releases }};
if [ `find . -maxdepth 1 -type d ! -path . | wc -l` -gt {{ $keep }} ]; then
sudo rm -rf `ls -t | tail -n +{{ $remove }}`;
fi
@endtask
@task('graceful')
sudo apache2ctl graceful
@endtask
@after
@endafter
@task('rollback')
rm -rf {{ $release }};
@endtask