-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathDeploymentScriptSync.php
More file actions
37 lines (31 loc) · 1.33 KB
/
DeploymentScriptSync.php
File metadata and controls
37 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace App\Sync;
use Closure;
use Laravel\Forge\Exceptions\ValidationException;
use Laravel\Forge\Resources\Server;
use Laravel\Forge\Resources\Site;
use Laravel\Forge\Resources\Webhook;
class DeploymentScriptSync extends BaseSync
{
public function sync(string $environment, Server $server, Site $site, Closure $output, bool $force = false): void
{
$deploymentScript = is_array($script = $this->config->get($environment, 'deployment', '')) ? join("\n", $script) : $script;
$deploymentScriptOnForge = $this->forge->siteDeploymentScript($server->id, $site->id);
if (!$force && $deploymentScript !== $deploymentScriptOnForge) {
$output("Skipping the deployment script update, as the script on Forge is different than your local script.\nUse --force to overwrite it.", 'warn');
return;
}
$this->forge->updateSiteDeploymentScript($server->id, $site->id, $deploymentScript);
if ($this->config->get($environment, 'quick-deploy')) {
try {
$site->enableQuickDeploy();
} catch (ValidationException $e) {
if (! in_array('Hook already exists on this repository', $e->errors())) {
throw $e;
}
}
} else {
$site->disableQuickDeploy();
}
}
}