-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.php
105 lines (82 loc) · 2.33 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Tasks
//Generate optimize bundles
task('fix:npm_build', function () {
run('npm run build:back');
run('npm run build:front');
})->local();
//Send optimize functions
task('fix:npm_send', function () {
upload("public/bundle-back.js", '{{release_path}}/public/bundle-back.js');
upload("public/bundle-front.js", '{{release_path}}/public/bundle-front.js');
});
//Send optimize functions
task('fix:template_send', function () {
upload("public/app-assets/", '{{release_path}}/public/app-assets/');
});
//Fixed user-own
task('fix:permisions', function () {
run('sudo chown www-data:www-data {{release_path}}/../../ -R');
});
//Fixed user-own before
task('fix:permisions_before', function () {
run('sudo chown ${USER}:${USER} {{release_path}}/../../ -R');
});
//Group Fix
task('fix', [
'fix:npm_build',
'fix:permisions_before',
'fix:npm_send',
'fix:template_send',
'fix:permisions',
]);
task('build', function () {
run('cd {{release_path}} && build');
});
//Group Fix
task('sdk-deploy', [
'deploy',
'fix',
]);
//Global config
set('http_user', 'www-data');
// set permisions
set('writable_use_sudo', true);
set('clear_use_sudo', true);
set('cleanup_use_sudo', true);
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
//back to previus release
// task('npm', function () {
// if (has('previous_release')) {
// run('cp -R {{previous_release}}/node_modules {{release_path}}/node_modules');
// }
//
// run('cd {{release_path}} && npm install');
// });
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'artisan:migrate');
// add('shared_files', ['public/app-assets']);
add('shared_dirs', ['public/app-assets']);
// Hosts
/* Example
host('capmega.com')
->stage('production')
// ->set('user', 'www-data')
->port(22)
->set('deploy_path', '/var/www/html/{{application}}');
host('trial.capmega.com')
->stage('staging')
// ->set('user', 'www-data')
->port(22)
->set('deploy_path', '/var/www/html/{{application}}');
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
*/