This repository has been archived by the owner on Oct 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
74 lines (62 loc) · 1.6 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
<?php
namespace Deployer;
require 'recipe/common.php';
// Project name
set('application', 'kwai_api');
if (!has('public_path')) {
set('public_path', '/www');
}
set('ssh_multiplexing', false);
// Shared files/dirs between deploys
set('shared_files', []);
set('shared_dirs', ['files', 'config']);
// Writable dirs by web server
set('writable_dirs', []);
// Hosts
inventory('hosts.yml');
// Tasks
task('deploy:staging', function() {
$appFiles = [
'api',
'src',
'autoload.php',
'composer.json',
'composer.lock'
];
$releasePath = get('release_path');
foreach($appFiles as $file) {
upload($file, "{$releasePath}");
}
});
task('generate:autoload', function() {
// Generate a simple autoload file, which make it possible to use a PSR-4
// autoloader for classes that are located in a private folder.
run("mkdir -p {{public_path}}");
$realpath = run("readlink -f {{deploy_path}}");
run(
"echo \"<?php require('${realpath}/current/vendor/autoload.php');\" > {{public_path}}/autoload.php"
);
});
task('copy:api', function() {
run('cp -R {{release_path}}/api {{public_path}}');
});
desc('Deploy your project');
task('deploy', [
'deploy:info',
'deploy:prepare',
'deploy:lock',
'deploy:release',
'deploy:staging',
'deploy:shared',
'deploy:writable',
'deploy:vendors',
'deploy:clear_paths',
'deploy:symlink',
'generate:autoload',
'copy:api',
'deploy:unlock',
'cleanup',
'success'
]);
// [Optional] If deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');