mirror of
https://github.com/deployphp/deployer.git
synced 2025-02-23 16:54:08 +01:00
33 lines
757 B
PHP
33 lines
757 B
PHP
<?php
|
|
/* (c) Anton Medvedev <anton@medv.io>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace Deployer;
|
|
|
|
desc('Cleaning up old releases');
|
|
task('cleanup', function () {
|
|
$releases = get('releases_list');
|
|
|
|
$keep = get('keep_releases');
|
|
|
|
if ($keep === -1) {
|
|
// Keep unlimited releases.
|
|
return;
|
|
}
|
|
|
|
while ($keep - 1 > 0) {
|
|
array_shift($releases);
|
|
--$keep;
|
|
}
|
|
|
|
foreach ($releases as $release) {
|
|
run("rm -rf {{deploy_path}}/releases/$release");
|
|
}
|
|
|
|
run("cd {{deploy_path}} && if [ -e release ]; then rm release; fi");
|
|
run("cd {{deploy_path}} && if [ -h release ]; then rm release; fi");
|
|
});
|