Skip to content

Commit

Permalink
Merge pull request #7 from bakerkretzmar/check-quick-deploy-before-se…
Browse files Browse the repository at this point in the history
…tting

Silence error if quick deploy is already enabled
  • Loading branch information
mpociot authored Apr 12, 2021
2 parents c2f30fb + 9269853 commit b94b508
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions app/Sync/DeploymentScriptSync.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Sync;

use Illuminate\Console\OutputStyle;
use Laravel\Forge\Exceptions\ValidationException;
use Laravel\Forge\Resources\Server;
use Laravel\Forge\Resources\Site;
use Laravel\Forge\Resources\Webhook;
Expand All @@ -16,14 +17,20 @@ public function sync(string $environment, Server $server, Site $site, OutputStyl
$deploymentScriptOnForge = $this->forge->siteDeploymentScript($server->id, $site->id);

if (!$force && $deploymentScript !== $deploymentScriptOnForge) {
$output->warning("Skipping the deployment log update, as the script on Forge is different than your local script.\nUse --force to overwrite it.");
$output->warning("Skipping the deployment script update, as the script on Forge is different than your local script.\nUse --force to overwrite it.");
return;
}

$this->forge->updateSiteDeploymentScript($server->id, $site->id, $deploymentScript);

if ($this->config->get($environment, 'quick-deploy')) {
$site->enableQuickDeploy();
try {
$site->enableQuickDeploy();
} catch (ValidationException $e) {
if (! in_array('Hook already exists on this repository', $e->errors())) {
throw $e;
}
}
} else {
$site->disableQuickDeploy();
}
Expand Down

0 comments on commit b94b508

Please sign in to comment.