diff --git a/src/Bootstrap.php b/src/Bootstrap.php index 563bd06..a3e1e03 100644 --- a/src/Bootstrap.php +++ b/src/Bootstrap.php @@ -63,6 +63,10 @@ private function initContainer(): Container $container = $builder->build(); + if (!defined('DEPLOYER_VERSION')) { + define("DEPLOYER_VERSION", sprintf("Hypernode Deploy %s", $this->getVersion())); + } + $this->registerTwigLoader($container); return $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/Deployer/Task/Common/DefaultsTaskGlobal.php b/src/Deployer/Task/Common/DefaultsTaskGlobal.php index 202a344..a899762 100644 --- a/src/Deployer/Task/Common/DefaultsTaskGlobal.php +++ b/src/Deployer/Task/Common/DefaultsTaskGlobal.php @@ -42,7 +42,11 @@ public function configure(Configuration $config): void }); set('commit_sha', function () { - return $this->releaseInfo->getCommitSha(); + try { + return $this->releaseInfo->getCommitSha(); + } catch (\Throwable $e) { + return ''; + } }); if (str_starts_with($config->getPhpVersion(), 'php')) { diff --git a/src/Stdlib/ReleaseInfo.php b/src/Stdlib/ReleaseInfo.php index 3be2fc6..c819f41 100644 --- a/src/Stdlib/ReleaseInfo.php +++ b/src/Stdlib/ReleaseInfo.php @@ -2,6 +2,7 @@ namespace Hypernode\Deploy\Stdlib; +use Deployer\Exception\RunException; use Hypernode\DeployConfiguration\Stage; use function Deployer\get; @@ -52,7 +53,13 @@ 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) { + return []; + } if (!preg_match(self::MERGE_PATTERN, $gitLogOutput, $matches)) { output()->write('No merge commit found');