forked from jpennors/fablab_webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
78 lines (58 loc) · 2.05 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
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Configuration
set('keep_releases', 3);
set('ssh_type', 'native');
set('ssh_multiplexing', false);
set('repository', '[email protected]:smarchie/fablab-webapp.git');
set('writable_use_sudo', false);
set('bin/php', '/opt/plesk/php/7.1/bin/php');
set('bin/composer', '{{bin/php}} /usr/lib/plesk-9.0/composer.phar');
set('bin/npm', function() {
if(commandExist('npm-cache')) {
return run('which npm-cache')->toString();
}
return run('which npm')->toString();
});
add('shared_files', [ '.env', 'resources/app/env.js' ]);
add('shared_dirs', []);
add('writable_dirs', []);
// Servers
serverList('servers.yml');
// Tasks
desc('Restart PHP-FPM service');
task('php-fpm:restart', function () {
// The user must have rights for restart service
// /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
run('systemctl restart php-fpm.service');
});
#after('deploy:symlink', 'php-fpm:restart');
task('npm:install', function() {
run('cd {{release_path}} && {{bin/npm}} install npm');
});
task('gulp', function() {
run('cd {{release_path}} && node_modules/.bin/gulp');
});
desc('Execute artisan config:clear');
task('artisan:config:clear', function () {
run('{{bin/php}} {{release_path}}/artisan config:clear');
});
before('deploy:symlink', 'npm:install');
after('npm:install', 'gulp');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
// desc('Execute artisan migrate:fresh');
task('artisan:migrate:fresh', function () {
run('{{bin/php}} {{release_path}}/artisan migrate:fresh --force');
});
//desc('Execute artisan db:seed');
desc('Execute artisan db:seed');
task('artisan:db:seed', function () {
$output = run('{{bin/php}} {{release_path}}/artisan db:seed --force');
writeln('<info>' . $output . '</info>');
});
before('deploy:symlink', 'artisan:migrate:fresh');
after('artisan:migrate:fresh', 'artisan:db:seed');
before('deploy:symlink', 'artisan:config:clear');