forked from deployphp/deployer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
magento2.php
99 lines (85 loc) · 2.43 KB
/
magento2.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
<?php
namespace Deployer;
require_once __DIR__ . '/common.php';
add('recipes', ['magento2']);
// Configuration
// By default setup:static-content:deploy uses `en_US`.
// To change that, simply put set('static_content_locales', 'en_US de_DE');`
// in you deployer script.
set('static_content_locales', 'en_US');
set('shared_files', [
'app/etc/env.php',
'var/.maintenance.ip',
]);
set('shared_dirs', [
'var/composer_home',
'var/log',
'var/cache',
'var/export',
'var/report',
'var/import_history',
'var/session',
'var/importexport',
'var/backups',
'var/tmp',
'pub/sitemaps',
'pub/media'
]);
set('writable_dirs', [
'var',
'pub/static',
'pub/media',
'generated'
]);
set('clear_paths', [
'generated/*',
'pub/static/_cache/*',
'var/generation/*',
'var/cache/*',
'var/page_cache/*',
'var/view_preprocessed/*'
]);
// Tasks
desc('Compile magento di');
task('magento:compile', function () {
run("{{bin/php}} {{release_path}}/bin/magento setup:di:compile");
run('cd {{release_path}} && {{bin/composer}} dump-autoload -o');
});
desc('Deploy assets');
task('magento:deploy:assets', function () {
run("{{bin/php}} {{release_path}}/bin/magento setup:static-content:deploy {{static_content_locales}}");
});
desc('Enable maintenance mode');
task('magento:maintenance:enable', function () {
run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/bin/magento maintenance:enable; fi");
});
desc('Disable maintenance mode');
task('magento:maintenance:disable', function () {
run("if [ -d $(echo {{current_path}}) ]; then {{bin/php}} {{current_path}}/bin/magento maintenance:disable; fi");
});
desc('Upgrade magento database');
task('magento:upgrade:db', function () {
run("{{bin/php}} {{release_path}}/bin/magento setup:upgrade --keep-generated");
});
desc('Flush Magento Cache');
task('magento:cache:flush', function () {
run("{{bin/php}} {{release_path}}/bin/magento cache:flush");
});
desc('Magento2 deployment operations');
task('deploy:magento', [
'magento:compile',
'magento:deploy:assets',
'magento:maintenance:enable',
'magento:upgrade:db',
'magento:cache:flush',
'magento:maintenance:disable'
]);
desc('Deploy your project');
task('deploy', [
'deploy:prepare',
'deploy:vendors',
'deploy:clear_paths',
'deploy:magento',
'deploy:publish',
]);
after('deploy:failed', 'magento:maintenance:disable');