-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
52 lines (41 loc) · 1.49 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
<?php
namespace Deployer;
require 'recipe/symfony.php';
set('branch', function() {
return runLocally('git describe master --abbrev=0');
});
set('env', ['APP_ENV' => 'prod']);
set('shared_dirs', ['var/log', 'var/sessions', 'var/lock']);
set('shared_files', ['.env.local.php']);
set('clear_paths', ['node_modules']);
set('keep_releases', -1);
import('deploy.yaml');
after('deploy:failed', 'deploy:unlock');
after('deploy:symlink', 'deploy:clear_paths');
desc('Save version name');
task('deploy:version', function() {
$version = runLocally('git describe master --abbrev=0') === get('target') ? get('target') : get('release_revision');
run("echo '$version' > {{release_path}}/version");
});
after('deploy:update_code', 'deploy:version');
desc('Build assets');
task('deploy:build_assets', function() {
cd('{{release_path}}');
run('{{bin/npm}} clean-install; {{bin/npm}} run build');
});
after('deploy:vendors', 'deploy:build_assets');
desc('Clear PHP opcache');
task('deploy:clear_opcache', function() {
cd('{{release_path}}');
run('cachetool opcache:reset --web --web-path {{public_dir}} --web-url http://{{domain}}');
});
after('deploy:symlink', 'deploy:clear_opcache');
after('rollback', 'deploy:clear_opcache');
desc('Enable maintenance mode');
task('maintenance:enable', function() {
run('touch {{current_path}}/var/lock/maintenance.lock');
});
desc('Disable maintenance mode');
task('maintenance:disable', function() {
run('rm -f {{current_path}}/var/lock/maintenance.lock');
});