-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.php
61 lines (41 loc) · 1.46 KB
/
deploy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
namespace Deployer;
require 'recipe/laravel.php';
// Project name
set('application', 'my_project');
set('http_user', 'root');
set('writable_mode', 'chmod');
set('allow_anonymous_stats', false);
// Project repository
set('repository', 'https://github.com/tayron/laravel-crud-constance-teste.git');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);
// Path to deploy
set('deploy_path', '/var/www/html');
// Tasks
task('build', function () {
run('cd {{release_path}} && build');
});
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");
// Remove release
run("rm -rf {{deploy_path}}/releases/{$releases[0]}/");
writeln("Rollback to {$releases[1]} release was successful");
} else {
writeln("<error>no more releases you can revert to</error>");
}
});
desc('Running unit test');
task('test', function () {
runLocally('cd {{deploy_path}}/current/ && composer install --dev && php vendor/bin/phpunit');
});
after('deploy', 'test');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// Migrate database before symlink new release.
before('deploy:symlink', 'artisan:migrate');