-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeploy.php
73 lines (57 loc) · 2.35 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
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace Deployer;
require 'recipe/symfony4.php';
// Project name
set('application', 'deployed_community');
// Project repository
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', true);
set('keep_releases', 3);
// Shared files/dirs between deploys
add('shared_files', []);
add('shared_dirs', []);
// Writable dirs by web server
add('writable_dirs', []);
host('[email protected]')
->set('deploy_path', '/var/www/{{application}}');
// Tasks
task('build', function () {
run('cd {{release_path}} && composer install --no-dev --optimize-autoloader');
run('cd {{release_path}} && npm install');
run('cd {{release_path}} && ./node_modules/.bin/encore production');
// run('cd {{release_path}} && composer install --no-dev --optimize-autoloader && npm install && ./node_modules/.bin/encore production');
});
// Migrate database before symlink new release.
task('database:migrate', function () {
run('{{bin/php}} {{bin/console}} doctrine:schema:update --force');
})->desc('Migrate database');
// before('deploy:symlink', 'database:migrate');
task('tag_version', function () {
run('echo ------------------ > version.txt');
run('echo ------ `TZ="Europe/Paris" date -R` ------ >> version.txt');
run('echo ------------------ >> version.txt');
run('echo ---------COUCOU IBOU---------');
run('echo "Author Name : `git config --get user.name`" >> version.txt');
run('echo "Author Email : `git config --get user.email`" >> version.txt');
run('echo "Author Machine : `hostname -f`" >> version.txt');
run('echo "Author IP : `hostname -I`" >> version.txt');
run('echo "Revision : `git name-rev --name-only $(git rev-parse HEAD)`" >> version.txt');
run('git log --pretty=format:"%h%x09%an%x09%ad%x09%s" | head -n 5 >> version.txt');
})->local();
task('upload', function () {
upload(__DIR__ . '/version.txt', '{{release_path}}');
});
task('release', [
'build',
'tag_version',
'upload',
]);
after('deploy:symlink', 'release');
task('database:migrate', function () {
run('{{bin/console}} doctrine:schema:update --force');
run('{{bin/console}} elastic:reindex');
})->desc('Migrate database');
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
after('deploy:symlink', 'database:migrate');