Skip to content

Better support slack notifications #131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/DeployRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/Deployer/Task/After/SlackTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}}');
Expand Down
6 changes: 5 additions & 1 deletion src/Deployer/Task/Common/DefaultsTaskGlobal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')) {
Expand Down
9 changes: 8 additions & 1 deletion src/Stdlib/ReleaseInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Hypernode\Deploy\Stdlib;

use Deployer\Exception\RunException;
use Hypernode\DeployConfiguration\Stage;

use function Deployer\get;
Expand Down Expand Up @@ -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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return []; here as well right?

return [];
}

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