forked from shukla141015/keys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.php
77 lines (51 loc) · 1.68 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
<?php
namespace Deployer;
require 'recipe/laravel.php';
set('application', 'Keys');
set('repository', 'git@github.com:SjorsO/keys.git');
// Has to be false, otherwise deploying from a Github action will fail with an
// "TTY mode requires /dev/tty to be read/writable." error.
//
// If this is set to "true", you can see the "git pull" output.
set('git_tty', false);
set('keep_releases', 5);
host('sjors@keys.lol')->set('deploy_path', '/var/www/keys');
task('build-npm-assets', 'npm i; npm run prod');
task('clear-opcache', 'sudo service php7.4-fpm reload');
task('delete-unnecessary-release-dirs', function () {
$directoryNames = ['node_modules', 'tests', '.git'];
$deployPath = get('deploy_path');
// All releases, except the current release
$releases = get('releases_list');
// Name of the current release
array_push($releases, get('release_name'));
foreach ($directoryNames as $directoryName) {
foreach ($releases as $release) {
$directoryPath = escapeshellarg("$deployPath/releases/$release/$directoryName");
run("if [ -d $directoryPath ]; then rm -rf $directoryPath; fi");
}
}
});
after('deploy:failed', 'deploy:unlock');
task('deploy', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:vendors',
'build-npm-assets',
'deploy:writable',
// 'artisan:storage:link',
'artisan:view:clear',
'artisan:config:cache',
'artisan:route:cache',
'artisan:migrate',
'deploy:symlink',
'clear-opcache',
'artisan:queue:restart',
'deploy:unlock',
'cleanup',
'delete-unnecessary-release-dirs',
]);