Skip to content

Commit 843a982

Browse files
author
Igor Ludgero Miura
committed
Add the before_symlink_change config
1 parent 7b09fe8 commit 843a982

File tree

6 files changed

+37
-2
lines changed

6 files changed

+37
-2
lines changed

Configuration/General.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,15 @@
8888
}
8989
});
9090

91+
task('deploy:actions:before:symlink', function () {
92+
$beforeCommands = get("actions_before_symlink");
93+
if (count($beforeCommands) > 0) {
94+
foreach ($beforeCommands as $beforeCommand) {
95+
run("cd {{release_path}} && " . $beforeCommand);
96+
}
97+
}
98+
});
99+
91100
/**
92101
* ================================== GENERAL COMMANDS ============================================
93102
*/

Configuration/Mode/Full.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
invoke_custom('magento:di:compile');
4343
}
4444

45+
invoke_custom('deploy:actions:before:symlink');
4546
invoke_custom('deploy:symlink');
4647
invoke_custom('deploy:actions:after');
4748
invoke_custom('deploy:unlock');

Configuration/Mode/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
}
4949

5050
invoke_custom('magento:cache:flush');
51-
51+
invoke_custom('deploy:actions:before:symlink');
5252
invoke_custom('deploy:symlink');
5353
invoke_custom('deploy:actions:after');
5454
invoke_custom('deploy:unlock');

Model/Environment.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,11 @@ class Environment
135135
*/
136136
protected $ignoredSteps;
137137

138+
/**
139+
* @var array
140+
*/
141+
protected $actionsBeforeSymlinkChange;
142+
138143
const DEFAULT_SHARED_FILES = [
139144
'app/etc/env.php',
140145
'var/.maintenance.ip'
@@ -226,6 +231,9 @@ public function __construct(array $environmentData)
226231
$this->ignoredSteps = isset($environmentData["ignored_steps"])
227232
? $environmentData["ignored_steps"]
228233
: [];
234+
$this->actionsBeforeSymlinkChange = isset($environmentData["additional_commands"]["before_symlink_change"])
235+
? $environmentData["additional_commands"]["before_symlink_change"]
236+
: [];
229237
}
230238

231239
/**
@@ -611,4 +619,20 @@ public function setIgnoredSteps(array $ignoredSteps)
611619
{
612620
$this->ignoredSteps = $ignoredSteps;
613621
}
622+
623+
/**
624+
* @return array
625+
*/
626+
public function getActionsBeforeSymlinkChange(): array
627+
{
628+
return $this->actionsBeforeSymlinkChange;
629+
}
630+
631+
/**
632+
* @param array $actionsBeforeSymlinkChange
633+
*/
634+
public function setActionsBeforeSymlinkChange(array $actionsBeforeSymlinkChange)
635+
{
636+
$this->actionsBeforeSymlinkChange = $actionsBeforeSymlinkChange;
637+
}
614638
}

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "imaginationmedia/deployer-magento2",
33
"type": "php-package",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"license": "OSL-3.0",
66
"description": "Deploy a Magento 2 website using deployer.org",
77
"homepage": "https://www.imaginationmedia.com/",

deploy.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ function glob_recursive($pattern, $flags = 0)
116116
->set('slack_success_text', $environment->getSlackSuccessText())
117117
->set('slack_failure_text', $environment->getSlackFailureText())
118118
->set('ignored_steps', $environment->getIgnoredSteps())
119+
->set('actions_before_symlink', $environment->getActionsBeforeSymlinkChange())
119120
->identityFile($environment->getIdentityFile())
120121
->addSshOption('UserKnownHostsFile', '/dev/null')
121122
->addSshOption('StrictHostKeyChecking', 'no');

0 commit comments

Comments
 (0)