forked from OpenDominion/OpenDominion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
81 lines (64 loc) · 1.73 KB
/
deploy.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
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Config
set('repository', '[email protected]:WaveHack/OpenDominion.git');
set('branch', 'master');
set('ssh_multiplexing', false);
// Hosts
host('opendominion.net')
->set('deploy_path', '/var/www/opendominion.net')
->configFile('~/.ssh/config');
// Task definitions
desc('Installing NPM dependencies');
task('npm install', function () {
if (has('previous_release')) {
run('cp -R {{previous_release}}/node_modules {{release_path}}/node_modules');
}
run('cd {{release_path}} && npm install');
});
desc('Build frontend');
task('npm run prod', function () {
run('cd {{release_path}} && npm run prod');
});
desc('Update version');
task('artisan:version:update', function () {
run('cd {{release_path}} && {{bin/php}} artisan version:update');
});
desc('Reload php-fpm');
task('php-fpm:reload', function () {
run('sudo service php7.2-fpm reload');
});
desc('Restart supervisor workers');
task('supervisorctl:restart', function () {
run('sudo supervisorctl restart all');
});
// Execute tasks
task('deploy', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:vendors',
'npm install', //
'npm run prod', //
'deploy:writable',
'artisan:storage:link',
'artisan:view:clear',
'artisan:cache:clear',
'artisan:config:cache',
'artisan:optimize',
'artisan:down', //
'artisan:migrate', //
'artisan:version:update', //
'deploy:symlink',
'php-fpm:reload', //
'supervisorctl:restart', //
'artisan:up', //
'deploy:unlock',
'cleanup',
]);
after('deploy:failed', 'deploy:unlock');
after('deploy:failed', 'artisan:up');