Skip to content

Commit 27a71ae

Browse files
authored
Merge pull request #131 from ByteInternet/feature/support-slack-notifications
Better support slack notifications
2 parents 0de0ad4 + 30b6d34 commit 27a71ae

File tree

5 files changed

+19
-3
lines changed

5 files changed

+19
-3
lines changed

src/Bootstrap.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ private function initContainer(): Container
6363

6464
$container = $builder->build();
6565

66+
if (!defined('DEPLOYER_VERSION')) {
67+
define("DEPLOYER_VERSION", sprintf("Hypernode Deploy %s", $this->getVersion()));
68+
}
69+
6670
$this->registerTwigLoader($container);
6771

6872
return $container;

src/DeployRunner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ private function configureStageServer(
223223
$host->setSshMultiplexing(true);
224224
$host->set('roles', $server->getRoles());
225225
$host->set('domain', $stage->getDomain());
226+
$host->set('stage', $stage->getName());
226227
$host->set('deploy_path', function () {
227228
// Ensure directory exists before returning it
228229
run('mkdir -p ~/apps/{{domain}}/shared');

src/Deployer/Task/After/SlackTask.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function supports(TaskConfigurationInterface $config): bool
3535
*/
3636
public function configureWithTaskConfig(TaskConfigurationInterface $config): ?Task
3737
{
38-
$this->recipeLoader->load('slack.php');
38+
$this->recipeLoader->load('../contrib/slack.php');
3939

4040
set('slack_webhook', $config->getWebHook());
4141
set('slack_text', '{{release_message}}');

src/Deployer/Task/Common/DefaultsTaskGlobal.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public function configure(Configuration $config): void
4242
});
4343

4444
set('commit_sha', function () {
45-
return $this->releaseInfo->getCommitSha();
45+
try {
46+
return $this->releaseInfo->getCommitSha();
47+
} catch (\Throwable $e) {
48+
return '';
49+
}
4650
});
4751

4852
if (str_starts_with($config->getPhpVersion(), 'php')) {

src/Stdlib/ReleaseInfo.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Hypernode\Deploy\Stdlib;
44

5+
use Deployer\Exception\RunException;
56
use Hypernode\DeployConfiguration\Stage;
67

78
use function Deployer\get;
@@ -52,7 +53,13 @@ public function getMessage(): string
5253
*/
5354
private function branchList(): array
5455
{
55-
$gitLogOutput = runLocally('git log --merges -n 1');
56+
$gitLogOutput = '';
57+
58+
try {
59+
$gitLogOutput = runLocally('git log --merges -n 1');
60+
} catch (RunException $e) {
61+
return [];
62+
}
5663

5764
if (!preg_match(self::MERGE_PATTERN, $gitLogOutput, $matches)) {
5865
output()->write('No merge commit found');

0 commit comments

Comments
 (0)