Repository navigation
Expand file tree
/
Copy pathdeploy.php
More file actions
162 lines (141 loc) · 5.31 KB
/
Copy pathdeploy.php
File metadata and controls
162 lines (141 loc) · 5.31 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
<?php
/**
* @author Hipex <info@hipex.io>
* @copyright (c) Hipex B.V. ${year}
*/
/** @noinspection PhpUnhandledExceptionInspection */
namespace HipexDeployConfiguration;
use HipexDeployConfiguration\Command\Build\Composer;
use HipexDeployConfiguration\Command\Build\Shopware6\ShopwareRecovery;
use HipexDeployConfiguration\Command\Command;
use HipexDeployConfiguration\Command\Deploy\Shopware6\CacheClear;
use HipexDeployConfiguration\Command\DeployCommand;
use function Deployer\write;
use function Deployer\writeln;
use function Deployer\run;
$configuration = new Configuration('git@git.bluebirdday.nl:shopware6/shopware-demo.git');
$configuration->setPhpVersion('php74');
$configuration->setPublicFolder('public');
$configuration->setSharedFiles([
'.env',
]);
$configuration->setSharedFolders([
//'custom/plugins',
'config/jwt',
'files',
'var/log',
'public/media',
'public/thumbnail',
'public/sitemap',
]);
$configuration->setDeployExclude(
array_merge(
$configuration->getDeployExclude(),
[
'code_quality_check.sh',
'auth.json.sample',
'CHANGELOG.md',
'composer-cache',
'COPYING.txt',
'.editorconfig',
'grunt-config.json.sample',
'Gruntfile.js.sample',
'.htaccess',
'.htaccess.sample',
'LICENSE_AFL.txt',
'LICENSE_EE.txt',
'LICENSE.txt',
'nginx.conf.sample',
'package.json.sample',
'.php_cs.dist',
'phpserver',
'README_EE.md',
'SECURITY.md',
'.travis.yml.sample',
'build_frontend_dev.sh',
'local-php-security-checker',
'send_performance_annotation',
'php-security-checker',
'phpstan.neon',
'build_fe.sh',
'README.md',
'postpull.sh',
'magepack.config.js',
'vendor/snowdog/frontools',
'.dockerignore',
'docker-compose.yml',
'Dockerfile',
'easy-coding-standard.php',
'license.txt',
'phpstan.neon',
'PLATFORM_COMMIT_SHA',
'psalm.xml',
'phpunit.xml.dist',
'env.dist',
'var/cache/*'
]
)
);
$productionStage = $configuration->addStage('production', 'shopware.bluebirdday.io', 'shopware');
$productionStage->addServer('production1038.hipex.io');
$composerInstallArguments = [
'--verbose',
'--no-progress',
'--no-interaction',
'--optimize-autoloader',
'--ignore-platform-reqs',
];
// $configuration->addBuildCommand(new Command('mkdir -p custom/plugins'));
$configuration->addBuildCommand(new Composer($composerInstallArguments));
$configuration->addBuildCommand(new ShopwareRecovery());
// The following commands also do theme:compile and assets:install
$configuration->addBuildCommand(new Command('CI=1 SHOPWARE_SKIP_BUNDLE_DUMP=1 ./bin/build-administration.sh'));
$configuration->addBuildCommand(new Command('CI=1 SHOPWARE_SKIP_BUNDLE_DUMP=1 ./bin/build-storefront.sh'));
function getPlugins(): array
{
$output = explode("\n", run('cd {{release_path}} && {{bin/php}} bin/console plugin:list'));
// Take line over headlines and count "-" to get the size of the cells.
$lengths = array_filter(array_map('strlen', explode(' ', $output[4])));
$splitRow = function ($row) use ($lengths) {
$columns = [];
foreach ($lengths as $length) {
$columns[] = trim(substr($row, 0, $length));
$row = substr($row, $length + 1);
}
return $columns;
};
$headers = $splitRow($output[5]);
$splitRowIntoStructure = function ($row) use ($splitRow, $headers) {
$columns = $splitRow($row);
return array_combine($headers, $columns);
};
// Ignore first seven lines (headline, title, table, ...).
$rows = array_slice($output, 7, -3);
$plugins = [];
foreach ($rows as $row) {
$pluginInformation = $splitRowIntoStructure($row);
$plugins[] = $pluginInformation;
}
write(print_r($plugins, true));
return $plugins;
}
$configuration->addDeployCommand(new DeployCommand('{{bin/php}} bin/console deployment:metadata:create'));
$configuration->addDeployCommand(new DeployCommand('{{bin/php}} bin/console database:migrate --all'));
$configuration->addDeployCommand(new DeployCommand('{{bin/php}} bin/console plugin:refresh'));
$configuration->addDeployCommand(new DeployCommand(
function () {
$plugins = getPlugins();
foreach ($plugins as $plugin) {
if ($plugin['Installed'] === 'Yes' && $plugin['Upgradeable'] == 'Yes') {
writeln("<info>Running plugin update for " . $plugin['Plugin'] . "</info>\n");
run("cd {{release_path}} && {{bin/php}} bin/console plugin:update " . $plugin['Plugin']);
}
}
}
));
//$configuration->addDeployCommand(new AssetInstall());
$configuration->addDeployCommand(new CacheClear());
$configuration->addDeployCommand(new DeployCommand('supervisorctl -c /etc/supervisor/$(whoami).conf restart all'));
$configuration->addDeployCommand(new DeployCommand('{{bin/php}} bin/console cache:warmup'));
$configuration->addDeployCommand(new DeployCommand('{{bin/php}} bin/console http:cache:warm:up'));
return $configuration;