1 | <?php |
||
2 | /* (c) Anton Medvedev <[email protected]> |
||
3 | * |
||
4 | * For the full copyright and license information, please view the LICENSE |
||
5 | * file that was distributed with this source code. |
||
6 | */ |
||
7 | |||
8 | namespace Deployer; |
||
9 | |||
10 | 8 | desc('Cleaning up old releases'); |
|
11 | task('deploy:cleanup', function () { |
||
12 | 4 | $releases = get('releases_list'); |
|
13 | 4 | $keep = get('keep_releases'); |
|
14 | 4 | $runOpts = []; |
|
15 | |||
16 | 4 | if ($keep === -1) { |
|
17 | // Keep unlimited releases. |
||
18 | return; |
||
19 | } |
||
20 | |||
21 | 4 | while ($keep > 0) { |
|
22 | 4 | array_shift($releases); |
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
23 | 4 | --$keep; |
|
24 | } |
||
25 | |||
26 | 4 | foreach ($releases as $release) { |
|
27 | 1 | run("rm -rf {{deploy_path}}/releases/$release", $runOpts); |
|
28 | } |
||
29 | |||
30 | 4 | run("cd {{deploy_path}} && if [ -e release ]; then rm release; fi", $runOpts); |
|
31 | }); |
||
32 |