forked from drush-ops/drush
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeployCommands.php
66 lines (56 loc) · 2.17 KB
/
DeployCommands.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
<?php
namespace Drush\Commands\core;
use Consolidation\SiteAlias\SiteAlias;
use Consolidation\SiteAlias\SiteAliasManagerAwareTrait;
use Consolidation\SiteProcess\ProcessManager;
use Drush\Commands\DrushCommands;
use Drush\Drush;
use Drush\SiteAlias\SiteAliasManagerAwareInterface;
class DeployCommands extends DrushCommands implements SiteAliasManagerAwareInterface
{
use SiteAliasManagerAwareTrait;
/**
* Run several commands after performing a code deployment.
*
* @command deploy
*
* @usage drush deploy -v -y
* Run updates with verbose logging and accept all prompts.
*
* @version 10.3
*
* @topics docs:deploy
*
* @throws \Exception
*/
public function deploy(): void
{
$self = $this->siteAliasManager()->getSelf();
$redispatchOptions = Drush::redispatchOptions();
$manager = $this->processManager();
$this->logger()->notice("Database updates start.");
$options = ['no-cache-clear' => true];
$process = $manager->drush($self, 'updatedb', [], $options + $redispatchOptions);
$process->mustRun($process->showRealtime());
$this->cacheRebuild($manager, $self, $redispatchOptions);
$this->logger()->success("Config import start.");
$process = $manager->drush($self, 'config:import', [], $redispatchOptions);
$process->mustRun($process->showRealtime());
$this->cacheRebuild($manager, $self, $redispatchOptions);
$this->logger()->success("Deploy hook start.");
$process = $manager->drush($self, 'deploy:hook', [], $redispatchOptions);
$process->mustRun($process->showRealtime());
}
/**
* @param ProcessManager $manager
* @param SiteAlias $self
* @param array $redispatchOptions
*/
public function cacheRebuild(ProcessManager $manager, SiteAlias $self, array $redispatchOptions): void
{
// It is possible that no updates were pending and thus no caches cleared yet.
$this->logger()->success("Cache rebuild start.");
$process = $manager->drush($self, 'cache:rebuild', [], $redispatchOptions);
$process->mustRun($process->showRealtime());
}
}