diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 563bd06..f88b22f 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -61,6 +61,10 @@ private function initContainer(): Container 'version' => $this->getVersion(), ]); + if (!defined('DEPLOYER_VERSION')) { + define("DEPLOYER_VERSION", sprintf("Hypernode Deploy %s", $this->getVersion())); + } + $container = $builder->build(); $this->registerTwigLoader($container); diff --git a/src/DeployRunner.php b/src/DeployRunner.php index 9307eb0..e9de6a1 100644 --- a/src/DeployRunner.php +++ b/src/DeployRunner.php @@ -223,6 +223,7 @@ private function configureStageServer( $host->setSshMultiplexing(true); $host->set('roles', $server->getRoles()); $host->set('domain', $stage->getDomain()); + $host->set('stage', $stage->getName()); $host->set('deploy_path', function () { // Ensure directory exists before returning it run('mkdir -p ~/apps/{{domain}}/shared'); diff --git a/src/Deployer/Task/After/SlackTask.php b/src/Deployer/Task/After/SlackTask.php index 1aab66d..f3d62ef 100644 --- a/src/Deployer/Task/After/SlackTask.php +++ b/src/Deployer/Task/After/SlackTask.php @@ -35,7 +35,7 @@ public function supports(TaskConfigurationInterface $config): bool */ public function configureWithTaskConfig(TaskConfigurationInterface $config): ?Task { - $this->recipeLoader->load('slack.php'); + $this->recipeLoader->load('../contrib/slack.php'); set('slack_webhook', $config->getWebHook()); set('slack_text', '{{release_message}}'); diff --git a/src/Stdlib/ReleaseInfo.php b/src/Stdlib/ReleaseInfo.php index 3be2fc6..19959d9 100644 --- a/src/Stdlib/ReleaseInfo.php +++ b/src/Stdlib/ReleaseInfo.php @@ -3,6 +3,7 @@ namespace Hypernode\Deploy\Stdlib; use Hypernode\DeployConfiguration\Stage; +use Deployer\Exception\RunException; use function Deployer\get; use function Deployer\parse; @@ -18,7 +19,11 @@ class ReleaseInfo public function getCommitSha(): string { - return runLocally('git rev-parse HEAD'); + try { + return runLocally('git rev-parse HEAD'); + } catch (\Throwable $e) { + return ''; + } } public function getMessage(): string @@ -52,7 +57,11 @@ public function getMessage(): string */ private function branchList(): array { - $gitLogOutput = runLocally('git log --merges -n 1'); + $gitLogOutput = ''; + try { + $gitLogOutput = runLocally('git log --merges -n 1'); + } catch (RunException $e) { + } if (!preg_match(self::MERGE_PATTERN, $gitLogOutput, $matches)) { output()->write('No merge commit found');