diff --git a/doc/configuration.md b/doc/configuration.md index 2660a42..ae08897 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -199,6 +199,22 @@ public function configure() } ``` +You can also set the `profile` property to load a profile file (.bash_profile, .profile, .bashrc, etc...) + +```php +use EasyCorp\Bundle\EasyDeployBundle\Server\Property; + +// ... + +public function configure() +{ + return $this->getConfigBuilder() + ->server('deployer@hostname1', ['app'], [Property::profile => 'path/to/.bash_profile']) + // ... + ; +} +``` + Common Hooks ------------ diff --git a/src/Server/Property.php b/src/Server/Property.php index 8ac7580..39f79b3 100644 --- a/src/Server/Property.php +++ b/src/Server/Property.php @@ -32,4 +32,5 @@ final class Property const templates_dir = 'templates_dir'; const use_ssh_agent_forwarding = 'use_ssh_agent_forwarding'; const web_dir = 'web_dir'; + const profile = 'profile'; } diff --git a/src/Task/TaskRunner.php b/src/Task/TaskRunner.php index 5189dba..7ce7cea 100644 --- a/src/Task/TaskRunner.php +++ b/src/Task/TaskRunner.php @@ -47,6 +47,10 @@ private function doRun(Server $server, string $shellCommand, array $envVars): Ta $shellCommand = sprintf('cd %s && %s', $server->get(Property::project_dir), $shellCommand); } + if ($server->has(Property::profile)) { + $shellCommand = sprintf('source %s; %s', $server->get(Property::profile), $shellCommand); + } + // env vars aren't set with $process->setEnv() because it causes problems // that can't be fully solved with inheritEnvironmentVariables() if (!empty($envVars)) {