-
Notifications
You must be signed in to change notification settings - Fork 1
/
Envoy.blade.php
86 lines (72 loc) · 1.94 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
@servers(['localhost' => '127.0.0.1'])
@setup
$dir = dirname(__DIR__);
$releasesPath = $dir . '/releases';
$storagePath = $dir . '/storage';
$envPath = $dir . '/.env';
$currentLink = $dir . '/current';
$release = date('YmdHis');
@endsetup
@story('deploy')
git
composer
yarn
links
flushes
optimizations
switch
purge
@endstory
@task('git')
[ -d {{ $releasesPath }} ] || mkdir {{ $releasesPath }};
cd {{ $releasesPath }};
git clone seraph:/git/web/onemore.git {{ $release }};
@endtask
@task('composer')
cd {{ $releasesPath }}/{{ $release }};
composer install;
@endtask
@task('yarn')
cd {{ $releasesPath }}/{{ $release }};
yarn;
yarn run prod;
@endtask
@task('links')
{{-- Copy the storage folder if it doesn't exist yet. --}}
if [ ! -d {{ $storagePath }} ]; then
cp -r {{ $releasesPath }}/{{ $release }}/storage {{ $storagePath }};
fi
{{-- Copy the .env file if it doesn't exist .yet. --}}
if [ ! -f {{ $envPath }} ]; then
cp {{ $releasesPath }}/{{ $release }}/.env.example {{ $envPath }};
fi
rm -rf {{ $releasesPath }}/{{ $release }}/storage;
ln -sfvT {{ $storagePath }} {{ $releasesPath }}/{{ $release }}/storage;
ln -sfvT {{ $envPath }} {{ $releasesPath }}/{{ $release }}/.env;
cd {{ $releasesPath }}/{{ $release }};
php artisan storage:link;
@endtask
@task('flushes')
cd {{ $releasesPath }}/{{ $release }};
php artisan migrate --force;
php artisan cache:clear;
@endtask
@task('optimizations')
cd {{ $releasesPath }}/{{ $release }};
php artisan optimize;
{{-- This one doesn't work... --}}
{{--php artisan config:cache;--}}
php artisan route:cache;
@endtask
@task('switch')
cd {{ $releasesPath }}/{{ $release }};
ln -sfvT {{ $releasesPath }}/{{ $release }} {{ $currentLink }};
sudo systemctl reload php7.0-fpm.service;
php artisan queue:restart;
@endtask
{{-- Delete all but the latest 3 releases --}}
@task('purge')
echo "Purging old releases...";
cd {{ $releasesPath }};
ls -t | tail -n +4 | xargs rm -rf;
@endtask