forked from PHP-Belarus/php.of.by
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
64 lines (50 loc) · 1.65 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
<?php
namespace Deployer;
require 'recipe/symfony.php';
// Project name
set('application', 'php.of.by');
// Shared files/dirs between deploys
set('shared_files', []);
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
set('allow_anonymous_stats', false);
set('writable_mode', 'chmod');
// Hosts
host(getenv('DEPLOY_HOST'))
->set('labels', ['stage' => 'production'])
->set('remote_user', getenv('DEPLOY_USER'))
->set('identity_file', '.travis/deploy.key')
->set('deploy_path', getenv('DEPLOY_PATH'));
// User for setting proper permissions
set('http_user', getenv('DEPLOY_USER'));
set('http_group', getenv('DEPLOY_USER'));
task('deploy:package_upload', function(){
// Upload code package to server
upload('package.tgz', sprintf('%s/package.tgz', get('deploy_path')));
})->desc('Upload code package to server');
task('deploy:package_extract', function() {
$deployPath = get('deploy_path');
run(sprintf('/bin/tar -xzf %s/package.tgz -C %s', $deployPath, get('release_path')));
// Store package with release
run(sprintf('/bin/mv %s/package.tgz %s', $deployPath, get('release_path')));
})->desc('Extract package');
// Tasks
desc('Deploy project');
task('deploy', [
'deploy:info',
'deploy:setup',
'deploy:lock',
'deploy:release',
'deploy:package_upload',
'deploy:package_extract',
'deploy:shared',
'deploy:writable',
'deploy:cache:clear',
'deploy:publish',
]);
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'database:migrate');