-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
93 lines (78 loc) · 2.08 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
<?php
/**
* If need migrations:
* php deployer.phar deploy dev
* php deployer.phar deploy prod
*
* If not need migrations
* php deployer.phar deploy-wo-migrate dev
* php deployer.phar deploy-wo-migrate prod
*/
require 'recipe/common.php';
set('repository', 'https://github.com/sartor/php-smart-home.git');
set('copy_dirs', [
'vendor',
]);
set('copy_shared_files', [
'yii',
'web/index.php',
'config/db.php',
]);
set('shared_dirs', [ // Must be set writable manually
'runtime',
'web/assets',
'web/images',
]);
server('sartorua', 'sartorua.com')
->user('sartor')
->forwardAgent()
->stage('prod')
->env('deploy_path', '~/sartorua.com')
->env('branch', 'master');
task('deploy:copy_shared_files', function () {
$files = get('copy_shared_files');
foreach ($files as $file) {
$src = "{{deploy_path}}/shared/$file";
$dst = "{{release_path}}/$file";
run("if [ -f $(echo $dst) ]; then rm -rf $dst; fi");
run("cp -pf $src $dst");
}
});
task('deploy:migrate', function () {
run('{{bin/php}} {{release_path}}/yii migrate up --interactive=0');
})->desc('Run migrations, crontab and flush cache');
task('cache', function () {
run('{{bin/php}} {{release_path}}/yii cache/flush-all');
});
task('deploy:vendor_clean', function () {
run('find {{release_path}}/vendor -type d | grep .git | xargs rm -rf');
});
task('deploy', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:copy_dirs',
'deploy:copy_shared_files',
'deploy:vendors',
'deploy:migrate',
'cache',
'deploy:vendor_clean',
'deploy:symlink',
'cleanup',
])->desc('Deploy project with migrations');
after('deploy', 'success');
task('deploy-wo-migrate', [
'deploy:prepare',
'deploy:release',
'deploy:update_code',
'deploy:shared',
'deploy:copy_dirs',
'deploy:copy_shared_files',
'deploy:vendors',
'cache',
'deploy:vendor_clean',
'deploy:symlink',
'cleanup',
])->desc('Deploy project without migrations');
after('deploy-wo-migrate', 'success');