mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-24 01:02:24 +01:00
25 lines
670 B
PHP
25 lines
670 B
PHP
<?php
|
|
namespace Deployer;
|
|
|
|
use Deployer\Exception\Exception;
|
|
|
|
desc('Rollback to previous release');
|
|
task('rollback', function () {
|
|
$releases = get('releases_list');
|
|
|
|
if (isset($releases[1])) {
|
|
$releaseDir = "{{deploy_path}}/releases/{$releases[1]}";
|
|
|
|
// Symlink to old release.
|
|
run("cd {{deploy_path}} && {{bin/symlink}} $releaseDir {{current_path}}");
|
|
|
|
// Remove release
|
|
run("rm -rf {{deploy_path}}/releases/{$releases[0]}");
|
|
|
|
|
|
writeln("<info>rollback</info> to {$releases[1]} release was <success>successful</success>");
|
|
} else {
|
|
throw new Exception("No more releases you can revert to.");
|
|
}
|
|
});
|