public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { // Make sure releases directory exists $connection->execute("mkdir -p {$environment->remote->path}/{$environment->remote->releaseDir}"); // Create a new release $release = date('YmdHis'); if (($branch = $context->getArgument(['b', 'branch'])) === null) { $branch = $environment->code->branch; } if (($commit = $context->getArgument(['c', 'commit'])) === null) { $commit = null; } // What SCM command? switch (strtolower($environment->code->scm)) { case 'git': if ($commit) { $command = "git clone {$environment->code->repo} --branch={$branch} {$release}&&cd {$release}&&git checkout {$commit}"; } else { $command = "git clone {$environment->code->repo} --depth=1 --branch={$branch} {$release}"; } break; case 'svn': $command = "svn checkout {$environment->code->repo} {$release}"; break; default: throw new \Exception("Unsupported SCM: {$environment->code->scm} should be one of GIT or SVN"); } // Execute release $connection->execute("cd {$environment->remote->deployTo}&&{$command}"); // Remove old symlink $connection->execute("rm -f {$environment->remote->currentRelease}"); // Create new symlink $connection->execute("cd {$environment->remote->path}&&ln -s -r {$environment->remote->releaseDir}/{$release} {$environment->remote->symlink}"); }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { // What SCM? if ($environment->code->scm == 'git') { $connection->execute("cd {$environment->remote->currentRelease}&&git reset HEAD&&git pull"); } elseif ($environment->code->scm == 'svn') { $connection->execute("cd {$environment->remote->currentRelease}&&svn up"); } }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { if ($connection->execute("if [ -d \"{$environment->remote->deployTo}\" ]; then echo 1; fi")) { $releases = $connection->execute("ls {$environment->remote->deployTo}"); $releases = explode("\n", trim($releases)); if (($trim = count($releases) - $environment->remote->keepReleases) > 0) { $releases = array_slice($releases, 0, $trim); foreach ($releases as $release) { $context->say("\tPruning {$release}..."); $connection->execute("rm -Rf {$environment->remote->deployTo}/{$release}"); } } } }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { $currentRelease = $environment->remote->currentRelease; // Make directories $context->say("\tCreating required directories..."); $connection->execute("mkdir -p {$currentRelease}/bootstrap/cache"); $connection->execute("mkdir -p {$currentRelease}/storage/app/public"); $connection->execute("mkdir -p {$currentRelease}/storage/framework/cache"); $connection->execute("mkdir -p {$currentRelease}/storage/framework/sessions"); $connection->execute("mkdir -p {$currentRelease}/storage/framework/views"); $connection->execute("mkdir -p {$currentRelease}/storage/logs"); // Change ownership $context->say("\tChanging ownership...."); $connection->execute("sudo chown fedora.apache {$currentRelease}/storage -R"); $connection->execute("sudo chown fedora.apache {$currentRelease}/bootstrap/cache -R"); // Change permissions $context->say("\tChanging permissions..."); $connection->execute("sudo chmod 770 {$currentRelease}/storage -R"); $connection->execute("sudo chmod 770 {$currentRelease}/bootstrap/cache -R"); // Link up the environment $context->say("\tLinking environment config..."); $connection->execute("cd {$currentRelease}&&ln -s .env.{$environment->name} .env"); }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { $connection->execute("sudo redis-cli flushdb"); }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { $connection->execute("cd {$context->config->remote->currentRelease}&&composer install"); }
public function run(Context $context, Environment $environment, ConnectionInterface $connection = null) { $connection->execute("cd {$environment->remote->currentRelease}/migrations&&./phinx migrate -e {$environment->name}", true); }