-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathEnvoy.blade.php
78 lines (66 loc) · 2.25 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
@servers(['local' => '127.0.0.1', 'web' => ['[email protected]']])
@setup
$now = new DateTime();
$branch = isset($branch) ? $branch : 'uat';
$repository = '[email protected]:maingocthanhtan96/larajs.git';
$original_dir = '/var/www/larajs';
$releases_dir = $original_dir . '/release';
$app_dir = $original_dir . '/app';
$release = $branch . '-' . date('YmdHis');
$new_release_dir = $releases_dir .'/'. $release;
@endsetup
@story('deploy', ['on' => 'web'])
clone_repository
run_composer
update_symlinks
run_deploy_scripts
delete_git_metadata
clean_old_releases
@endstory
@task('clone_repository')
echo 'Cloning repository'
[ -d {{ $releases_dir }} ] || mkdir {{ $releases_dir }}
git clone {{ $repository }} --branch={{ $branch }} --depth=1 -q {{ $new_release_dir }}
cd {{ $new_release_dir }}
@endtask
@task('run_composer')
echo "Starting deployment ({{ $release }})"
cd {{ $new_release_dir }}
echo "Running composer..."
php composer.phar install --prefer-dist --no-scripts -q -o
@endtask
@task('update_symlinks')
echo 'Linking .env file'
ln -nfs {{ $app_dir }}/.env {{ $new_release_dir }}/.env
echo 'Linking storage directory'
rm -rf {{ $new_release_dir }}/storage
ln -nfs {{ $app_dir }}/storage {{ $new_release_dir }}/storage
{{-- echo 'Linking vendor release'--}}
{{-- ln -nfs {{ $app_dir }}/vendor {{ $new_release_dir }}/vendor--}}
echo 'Linking current release'
ln -nfs {{ $new_release_dir }} {{ $original_dir }}/current
@endtask
@task('run_deploy_scripts')
echo 'Running deployment scripts'
cd {{ $new_release_dir }}
php artisan view:clear
php artisan cache:clear
php artisan config:clear
php artisan optimize
php artisan migrate --force
@endtask
@task('delete_git_metadata')
echo 'Delete .git folder'
cd {{ $new_release_dir }}
rm -rf .git
@endtask
@task('clean_old_releases')
# This will list our releases by modification time and delete all but the 2 most recent.
purging=$(ls -dt {{ $releases_dir }}/* | tail -n +5);
if [ "$purging" != "" ]; then
echo Purging old releases: $purging;
rm -rf $purging;
else
echo 'No releases found for purging at this time';
fi
@endtask