-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathM2PostDeployHook.php
More file actions
45 lines (40 loc) · 1.66 KB
/
M2PostDeployHook.php
File metadata and controls
45 lines (40 loc) · 1.66 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
<?php
class M2PostDeployHook implements Hooks_DeployerInterface
{
public function preDeployer(Deployer &$deployer)
{
//TODO : if enabled
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento maintenance:enable";
$this->runBashCommand($deployer, $bashCMD);
}
/**
* @param Deployer $deployer
*/
public function postDeployer(Deployer &$deployer)
{
NedStars_Log::message('Running Post Deploy commands:');
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php composer.phar install";
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento setup:upgrade 2>1 > /dev/null";
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento setup:di:compile 2>1 > /dev/null";
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento setup:static-content:deploy nl_NL en_US 2>1 > /dev/null";
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento maintenance:disable 2>1 > /dev/null"; //always disable maintainance mode
$bashCMD[] = "/root/.phpbrew/php/php-7.0.14/bin/php bin/magento cache:flush 2>1 > /dev/null";
$this->runBashCommand($deployer, $bashCMD);
}
/**
* @param Deployer $deployer
* @param array $bashCMD
* @return $this
*/
protected function runBashCommand(Deployer &$deployer, array $bashCMD)
{
$path = (string)$deployer->getConfig()->paths->web_live_path;
foreach ($bashCMD as $_bashCMD) {
$output = array();
$return = 0;
$command = "cd {$path} && {$_bashCMD}";
exec($command, $output, $return);
}
return $this;
}
}