-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
config.php
158 lines (137 loc) · 5.21 KB
/
config.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?php
namespace Deployer;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Yaml\Yaml;
use Deployer\Exception\RuntimeException;
use function getenv;
use function is_array;
use function preg_match;
use function ucfirst;
option('composer_auth', null, InputOption::VALUE_OPTIONAL, 'Add a composer authentification configuration');
// Neos specifc values
set('flow_context', 'Production/Live');
set('flow_command', 'FLOW_CONTEXT={{flow_context}} {{bin/php}} -d memory_limit=8G {{release_path}}/flow');
set('shared_dirs', [
'Data/Persistent',
'Data/Logs',
'Configuration'
]);
// To disable the upload you can set this to false: set('upload_assets_folder', false);
// Mostly used for rendered CSS & JS files, who you don't want in your repository
set('upload_assets_folder', [
'DistributionPackages/*/Resources/Private/Templates/InlineAssets',
'DistributionPackages/*/Resources/Public/Scripts',
'DistributionPackages/*/Resources/Public/Styles',
]);
set('db_name', static function (): string {
try {
$yaml = run('{{flow_command}} configuration:show --type Settings --path Neos.Flow.persistence.backendOptions');
return Yaml::parse($yaml)['dbname'];
} catch (RuntimeException $e) {
$name = has('database') ? '{{database}}' : camelCaseToSnakeCase(get('repository_short_name')) . '_neos';
$stage = !has('database') && has('stage') ? '_' . camelCaseToSnakeCase(get('stage')) : '';
return parse('{{user}}_' . $name . $stage);
}
});
set('redis_start_db_number', 2);
set('redis_defaultLifetime', 0);
set('redis_databases', [
'Flow_Mvc_Routing_Route',
'Flow_Mvc_Routing_Resolve',
'Neos_Fusion_Content',
'Flow_Session_MetaData',
'Flow_Session_Storage',
'Neos_Media_ImageSize',
'Flow_Security_Cryptography_HashService',
]);
set('redis_databases_with_numbers', static function (): array {
$start = get('redis_start_db_number', 2);
$databases = get('redis_databases', false);
$array = [];
if (is_array($databases)) {
foreach ($databases as $index => $database) {
$array[$database] = $start + $index;
}
}
return $array;
});
// Composer specific
set('composer_options', '{{composer_action}} --verbose --prefer-dist --no-progress --no-interaction --no-dev --optimize-autoloader');
// Git specifc values
set('bin/git', static function (): string {
return 'GIT_SSH_COMMAND="ssh -i ~/.ssh/' . get('ssh_key') . '" ' . locateBinaryPath('git');
});
set('repository_url_parts', static function (): array {
preg_match(
'/^(?:(?<user>[^@]*)@)?(?<host>[^:]*):(?<path>.*\/(?<short_name>.*))\.git$/',
get('repository'),
$urlParts
);
return $urlParts;
});
set('repository_short_name', static function (): string {
return get('repository_url_parts')['short_name'];
});
set('repository_link', static function (): string {
return 'https://' . get('repository_url_parts')['host'] . '/' . get('repository_url_parts')['path'];
});
set('deploy_user', static function (): string {
$user = getenv('GIT_AUTHOR_NAME');
if ($user === false) {
$user = getenv('GIT_COMMITTER_NAME');
if ($user === false) {
$getUserCommand = 'git config --get user.name';
if (!testLocally("$getUserCommand 2>/dev/null || true")) {
$user = runLocally($getUserCommand);
} else {
$user = get('user');
}
}
}
return $user;
});
set('git_commit_types', [
'Fix' => 'A bug fix',
'Update' => 'A backwards-compatible enhancement',
'Breaking' => 'A backwards-incompatible enhancement',
'Docs' => 'Documentation change',
'Build' => 'Build process update',
'New' => 'A new feature implementation',
'Upgrade' => 'Dependency upgrade',
'Chore' => 'Other changes (e.g.: refactoring)',
]);
// Connection specifc values
set('port', 22);
set('forwardAgent', false);
set('multiplexing', true);
set('ssh_key', get('repository_short_name'));
// Server specifc values
set('editor', 'nano');
set('html_path', '/var/www/virtual/{{user}}');
set('deploy_path', '{{html_path}}/{{deploy_folder}}');
set('db_backup_folder', '{{deploy_path}}/.dep/databases/dumps');
set('db_backup_keep_dumps', 5);
set('deploy_folder', static function (): string {
$suffix = '';
if (has('stage')) {
$suffix = "/" . ucfirst(get('stage'));
}
return get('repository_short_name') . $suffix;
});
set('db_password', static function (): string {
return run('my_print_defaults client | grep -Po "password=\K(\S)*"');
});
set('release_name', static function (): string {
return run('date +"%Y-%m-%d__%H-%M-%S"');
});
// Slack specifc values
set('slack_application', static function (): string {
return get('application', getRealHostname());
});
set('slack_title', '{{slack_application}} (Neos)');
set('slack_text', '_{{deploy_user}}_ deploying *{{repository_short_name}}* on `{{branch}}` to *{{target}}*');
set('slack_success_text', 'Deploy from *{{repository_short_name}}* to *{{target}}* successful');
set('slack_failure_text', 'Deploy from *{{repository_short_name}}* to *{{target}}* failed');
set('slack_color', '#4d91f7');
set('slack_success_color', '#00c100');
set('slack_failure_color', '#ff0909');