Skip to content

Commit

Permalink
feat: allow specifying an ssh remote user
Browse files Browse the repository at this point in the history
  • Loading branch information
innocenzi committed Sep 12, 2023
1 parent 05b5072 commit e2edb7f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ final class Configuration
public string $deployerDirectoryName = 'deployer';
public bool $triggersDeploymentsOnForge = false;
public bool $disableCache = false;
public ?string $sshRemoteUser = null;

// Forge configuration
public string $hostname;
Expand Down
8 changes: 4 additions & 4 deletions src/Forge.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ private function loadSettingsFromForge(): void
private function configureDeployer(): void
{
host($this->configuration->hostname)
->setRemoteUser($this->configuration->remoteUser)
->setRemoteUser($this->configuration->sshRemoteUser ?: $this->configuration->remoteUser)
->setDeployPath($this->configuration->deployPath);

// Required settings
Expand Down Expand Up @@ -150,10 +150,10 @@ private function configureSlackNotifications(): void
}

set('slack_webhook', $this->environment->slackWebhookUrl);
set('slack_title', '<{{repository_url}}|{{repository_name}}> ({{repository_branch}})');
set('slack_title', '{{site_url}}');
set('slack_text', implode("\n", [
'*{{commit_author}}* is deploying to <{{site_url}}> (<{{forge_site_url}}|see on Forge>)',
'*Workflow*: <{{runner_url}}|see on GitHub>',
'*{{commit_author}}* is deploying <{{repository_url}}|{{repository_name}}> ({{repository_branch}})',
'*Links*: <{{runner_url}}|GitHub workflow>, <{{forge_site_url}}|Forge site>',
'*Commit*: _{{commit_text}}_ (<{{commit_url}}|`{{commit_short_sha}}`>)',
]));
set('slack_success_text', 'Deployment successful.');
Expand Down
10 changes: 10 additions & 0 deletions src/ForgeRecipeBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,16 @@ public function setDeployerDirectory(string $name): self
return $this;
}

/**
* Specify a remote user to SSH with, instead of fetching the one from Forge.
*/
public function setSshRemoteUser(string $remoteUser): self
{
$this->configuration->sshRemoteUser = $remoteUser;

return $this;
}

/**
* Defines whether Forge deployments should be triggered when a deployment is successful.
*/
Expand Down

0 comments on commit e2edb7f

Please sign in to comment.