forked from BeWelcome/rox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.php
59 lines (46 loc) · 1.68 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
<?php
namespace Deployer;
require 'recipe/symfony4.php';
// Project name
set('application', 'BeWelcome');
// Project repository
set('repository', '[email protected]:BeWelcome/rox.git');
set('deploy_path', '~/{{application}}');
set('default_stage', 'staging');
// [Optional] Allocate tty for git clone. Default value is false.
set('git_tty', false);
// Shared files/dirs between deploys
add('shared_files', ['.env', '.env.local']);
add('shared_dirs', ['var/logs', 'var/sessions']);
// Writable dirs by web server
add('writable_dirs', ['data']);
desc('Create local .env file');
task('deployer:create-env', function () {
$localEnvPath = "{{release_path}}/.env.local";
if (!test("[ -s $localEnvPath ]")) {
run("echo 'APP_ENV=prod' >> $localEnvPath");
run("echo 'DB_HOST={{db_host}}' >> $localEnvPath");
run("echo 'DB_PORT={{db_port}}' >> $localEnvPath");
run("echo 'DB_NAME={{db_name}}' >> $localEnvPath");
run("echo 'DB_USER={{db_user}}' >> $localEnvPath");
run("echo 'DB_PASS={{db_pass}}' >> $localEnvPath");
writeln('Created file .env.local');
} else {
writeln('File .env.local already exists');
}
});
before('deploy:vendors', 'deployer:create-env');
desc('Dump .env files for production');
task('deploy:dump-env', function () {
$result = run('cd {{release_path}} && {{bin/composer}} dump-env prod');
writeln($result);
});
after('deploy:vendors', 'deploy:dump-env');
// Tasks
task('build', function () {
run('cd {{release_path}} && make build version');
});
// [Optional] if deploy fails automatically unlock.
after('deploy:failed', 'deploy:unlock');
// config.deployer.yml is git-ignored
inventory('config/deployer.yml');