@@ -51,22 +51,22 @@ discard block |
||
51 | 51 | use Deployer\Task\Context; |
52 | 52 | use Deployer\Utility\Httpie; |
53 | 53 | |
54 | -set('discord_webhook', function () { |
|
54 | +set('discord_webhook', function() { |
|
55 | 55 | return 'https://discordapp.com/api/webhooks/{{discord_channel}}/{{discord_token}}/slack'; |
56 | 56 | }); |
57 | 57 | |
58 | 58 | // Deploy messages |
59 | -set('discord_notify_text', function () { |
|
59 | +set('discord_notify_text', function() { |
|
60 | 60 | return [ |
61 | 61 | 'text' => parse(':information_source: **{{user}}** is deploying branch `{{branch}}` to _{{target}}_'), |
62 | 62 | ]; |
63 | 63 | }); |
64 | -set('discord_success_text', function () { |
|
64 | +set('discord_success_text', function() { |
|
65 | 65 | return [ |
66 | 66 | 'text' => parse(':white_check_mark: Branch `{{branch}}` deployed to _{{target}}_ successfully'), |
67 | 67 | ]; |
68 | 68 | }); |
69 | -set('discord_failure_text', function () { |
|
69 | +set('discord_failure_text', function() { |
|
70 | 70 | return [ |
71 | 71 | 'text' => parse(':no_entry_sign: Branch `{{branch}}` has failed to deploy to _{{target}}_'), |
72 | 72 | ]; |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | set('discord_message', 'discord_notify_text'); |
77 | 77 | |
78 | 78 | // Helpers |
79 | -task('discord_send_message', function () { |
|
79 | +task('discord_send_message', function() { |
|
80 | 80 | $message = get(get('discord_message')); |
81 | 81 | |
82 | 82 | Httpie::post(get('discord_webhook'))->jsonBody($message)->send(); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | // Tasks |
86 | 86 | desc('Tests messages'); |
87 | -task('discord:test', function () { |
|
87 | +task('discord:test', function() { |
|
88 | 88 | set('discord_message', 'discord_notify_text'); |
89 | 89 | invoke('discord_send_message'); |
90 | 90 | set('discord_message', 'discord_success_text'); |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | ->once(); |
96 | 96 | |
97 | 97 | desc('Notifies Discord'); |
98 | -task('discord:notify', function () { |
|
98 | +task('discord:notify', function() { |
|
99 | 99 | set('discord_message', 'discord_notify_text'); |
100 | 100 | invoke('discord_send_message'); |
101 | 101 | }) |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | ->isHidden(); |
104 | 104 | |
105 | 105 | desc('Notifies Discord about deploy finish'); |
106 | -task('discord:notify:success', function () { |
|
106 | +task('discord:notify:success', function() { |
|
107 | 107 | set('discord_message', 'discord_success_text'); |
108 | 108 | invoke('discord_send_message'); |
109 | 109 | }) |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | ->isHidden(); |
112 | 112 | |
113 | 113 | desc('Notifies Discord about deploy failure'); |
114 | -task('discord:notify:failure', function () { |
|
114 | +task('discord:notify:failure', function() { |
|
115 | 115 | set('discord_message', 'discord_failure_text'); |
116 | 116 | invoke('discord_send_message'); |
117 | 117 | }) |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | set('mattermost_failure_text', 'Deploy to **{{target}}** failed {{mattermost_failure_emoji}}'); |
92 | 92 | |
93 | 93 | desc('Notifies mattermost'); |
94 | -task('mattermost:notify', function () { |
|
94 | +task('mattermost:notify', function() { |
|
95 | 95 | if (null === get('mattermost_webhook')) { |
96 | 96 | return; |
97 | 97 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | }); |
113 | 113 | |
114 | 114 | desc('Notifies mattermost about deploy finish'); |
115 | -task('mattermost:notify:success', function () { |
|
115 | +task('mattermost:notify:success', function() { |
|
116 | 116 | if (null === get('mattermost_webhook')) { |
117 | 117 | return; |
118 | 118 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | }); |
134 | 134 | |
135 | 135 | desc('Notifies mattermost about deploy failure'); |
136 | -task('mattermost:notify:failure', function () { |
|
136 | +task('mattermost:notify:failure', function() { |
|
137 | 137 | if (null === get('mattermost_webhook')) { |
138 | 138 | return; |
139 | 139 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | return $stopResponseInfo['http_code'] === 200; |
132 | 132 | } |
133 | 133 | |
134 | -task('supervisord-monitor:restart', function () { |
|
134 | +task('supervisord-monitor:restart', function() { |
|
135 | 135 | if (supervisordIsAuthenticated()) { |
136 | 136 | $names = explode(',', get('supervisord_process_name')); |
137 | 137 | foreach ($names as $name) { |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | } |
149 | 149 | }); |
150 | 150 | |
151 | -task('supervisord-monitor:stop', function () { |
|
151 | +task('supervisord-monitor:stop', function() { |
|
152 | 152 | if (supervisordIsAuthenticated()) { |
153 | 153 | $names = explode(',', get('supervisord_process_name')); |
154 | 154 | foreach ($names as $name) { |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | } |
163 | 163 | }); |
164 | 164 | |
165 | -task('supervisord-monitor:start', function () { |
|
165 | +task('supervisord-monitor:start', function() { |
|
166 | 166 | if (supervisordIsAuthenticated()) { |
167 | 167 | $names = explode(',', get('supervisord_process_name')); |
168 | 168 | foreach ($names as $name) { |
@@ -55,7 +55,7 @@ |
||
55 | 55 | use PhpAmqpLib\Message\AMQPMessage; |
56 | 56 | |
57 | 57 | desc('Notifies RabbitMQ channel about deployment'); |
58 | -task('deploy:rabbit', function () { |
|
58 | +task('deploy:rabbit', function() { |
|
59 | 59 | |
60 | 60 | if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) { |
61 | 61 | throw new \RuntimeException("<comment>Please install php package</comment> <info>videlalvaro/php-amqplib</info> <comment>to use rabbitmq</comment>"); |
@@ -62,18 +62,18 @@ discard block |
||
62 | 62 | use Deployer\Utility\Httpie; |
63 | 63 | |
64 | 64 | // Title of project |
65 | -set('telegram_title', function () { |
|
65 | +set('telegram_title', function() { |
|
66 | 66 | return get('application', 'Project'); |
67 | 67 | }); |
68 | 68 | |
69 | 69 | // Telegram settings |
70 | -set('telegram_token', function () { |
|
70 | +set('telegram_token', function() { |
|
71 | 71 | throw new \Exception('Please, configure "telegram_token" parameter.'); |
72 | 72 | }); |
73 | -set('telegram_chat_id', function () { |
|
73 | +set('telegram_chat_id', function() { |
|
74 | 74 | throw new \Exception('Please, configure "telegram_chat_id" parameter.'); |
75 | 75 | }); |
76 | -set('telegram_url', function () { |
|
76 | +set('telegram_url', function() { |
|
77 | 77 | return 'https://api.telegram.org/bot' . get('telegram_token') . '/sendmessage'; |
78 | 78 | }); |
79 | 79 | |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | |
86 | 86 | desc('Notifies Telegram'); |
87 | -task('telegram:notify', function () { |
|
87 | +task('telegram:notify', function() { |
|
88 | 88 | if (!get('telegram_token', false)) { |
89 | 89 | warning('No Telegram token configured'); |
90 | 90 | return; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | ->hidden(); |
116 | 116 | |
117 | 117 | desc('Notifies Telegram about deploy finish'); |
118 | -task('telegram:notify:success', function () { |
|
118 | +task('telegram:notify:success', function() { |
|
119 | 119 | if (!get('telegram_token', false)) { |
120 | 120 | warning('No Telegram token configured'); |
121 | 121 | return; |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ->hidden(); |
147 | 147 | |
148 | 148 | desc('Notifies Telegram about deploy failure'); |
149 | -task('telegram:notify:failure', function () { |
|
149 | +task('telegram:notify:failure', function() { |
|
150 | 150 | if (!get('telegram_token', false)) { |
151 | 151 | warning('No Telegram token configured'); |
152 | 152 | return; |
@@ -13,13 +13,13 @@ |
||
13 | 13 | |
14 | 14 | namespace Deployer; |
15 | 15 | |
16 | -set('bin/yarn', function () { |
|
16 | +set('bin/yarn', function() { |
|
17 | 17 | return which('yarn'); |
18 | 18 | }); |
19 | 19 | |
20 | 20 | // In there is a {{previous_release}}, node_modules will be copied from it before installing deps with yarn. |
21 | 21 | desc('Installs Yarn packages'); |
22 | -task('yarn:install', function () { |
|
22 | +task('yarn:install', function() { |
|
23 | 23 | if (has('previous_release')) { |
24 | 24 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
25 | 25 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -61,12 +61,12 @@ discard block |
||
61 | 61 | use Deployer\Utility\Httpie; |
62 | 62 | |
63 | 63 | // Title of project based on git repo |
64 | -set('cimonitor_title', function () { |
|
64 | +set('cimonitor_title', function() { |
|
65 | 65 | $repo = get('repository'); |
66 | 66 | $pattern = '/\w+\/\w+/'; |
67 | 67 | return preg_match($pattern, $repo, $titles) ? $titles[0] : $repo; |
68 | 68 | }); |
69 | -set('cimonitor_user', function () { |
|
69 | +set('cimonitor_user', function() { |
|
70 | 70 | return [ |
71 | 71 | 'name' => runLocally('git config --get user.name'), |
72 | 72 | 'email' => runLocally('git config --get user.email'), |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | set('cimonitor_job_state_success', get('cimonitor_status_success')); |
87 | 87 | |
88 | 88 | desc('Notifies CIMonitor'); |
89 | -task('cimonitor:notify', function () { |
|
89 | +task('cimonitor:notify', function() { |
|
90 | 90 | if (!get('cimonitor_webhook', false)) { |
91 | 91 | return; |
92 | 92 | } |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | ->hidden(); |
113 | 113 | |
114 | 114 | desc('Notifies CIMonitor about deploy finish'); |
115 | -task('cimonitor:notify:success', function () { |
|
115 | +task('cimonitor:notify:success', function() { |
|
116 | 116 | if (!get('cimonitor_webhook', false)) { |
117 | 117 | return; |
118 | 118 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | ->hidden(); |
141 | 141 | |
142 | 142 | desc('Notifies CIMonitor about deploy failure'); |
143 | -task('cimonitor:notify:failure', function () { |
|
143 | +task('cimonitor:notify:failure', function() { |
|
144 | 144 | if (!get('cimonitor_webhook', false)) { |
145 | 145 | return; |
146 | 146 | } |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | } |
194 | 194 | |
195 | 195 | desc('Creates database though CPanel API'); |
196 | -task('cpanel:createdb', function () { |
|
196 | +task('cpanel:createdb', function() { |
|
197 | 197 | |
198 | 198 | $cpanel = getCPanel(); |
199 | 199 | $config = get('cpanel', []); |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | }); |
222 | 222 | |
223 | 223 | desc('Creates addon domain though CPanel API'); |
224 | -task('cpanel:createaddondomain', function () { |
|
224 | +task('cpanel:createaddondomain', function() { |
|
225 | 225 | $cpanel = getCPanel(); |
226 | 226 | $config = get('cpanel', []); |
227 | 227 | $domain = getDomainInfo()['domain']; |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | }); |
245 | 245 | |
246 | 246 | desc('Deletes addon domain though CPanel API'); |
247 | -task('cpanel:deleteaddondomain', function () { |
|
247 | +task('cpanel:deleteaddondomain', function() { |
|
248 | 248 | $cpanel = getCPanel(); |
249 | 249 | $config = get('cpanel', []); |
250 | 250 | $domain = getDomainInfo()['domain']; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | desc('Notifies Sentry of deployment'); |
66 | 66 | task( |
67 | 67 | 'deploy:sentry', |
68 | - static function () { |
|
68 | + static function() { |
|
69 | 69 | $now = date('c'); |
70 | 70 | |
71 | 71 | $defaultConfig = [ |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | $config = array_merge($defaultConfig, (array) get('sentry')); |
88 | 88 | array_walk( |
89 | 89 | $config, |
90 | - static function (&$value) use ($config) { |
|
90 | + static function(&$value) use ($config) { |
|
91 | 91 | if (is_callable($value)) { |
92 | 92 | $value = $value($config); |
93 | 93 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | |
223 | 223 | function getReleaseGitRef(): Closure |
224 | 224 | { |
225 | - return static function ($config = []): string { |
|
225 | + return static function($config = []): string { |
|
226 | 226 | if (get('update_code_strategy') === 'archive') { |
227 | 227 | if (isset($config['git_version_command'])) { |
228 | 228 | cd('{{deploy_path}}/.dep/repo'); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | function getGitCommitsRefs(): Closure |
247 | 247 | { |
248 | - return static function ($config = []): array { |
|
248 | + return static function($config = []): array { |
|
249 | 249 | $previousReleaseRevision = getPreviousReleaseRevision(); |
250 | 250 | $currentReleaseRevision = getCurrentReleaseRevision() ?: 'HEAD'; |
251 | 251 | |
@@ -266,13 +266,13 @@ discard block |
||
266 | 266 | $lines = array_filter( |
267 | 267 | // limit number of commits for first release with many commits |
268 | 268 | array_map('trim', array_slice(explode("\n", $result), 0, 200)), |
269 | - static function (string $line): bool { |
|
269 | + static function(string $line): bool { |
|
270 | 270 | return !empty($line) && strpos($line, 'commit') !== 0; |
271 | 271 | }, |
272 | 272 | ); |
273 | 273 | |
274 | 274 | return array_map( |
275 | - static function (string $line): array { |
|
275 | + static function(string $line): array { |
|
276 | 276 | [$ref, $authorName, $authorEmail, $timestamp, $message] = explode('#', $line, 5); |
277 | 277 | |
278 | 278 | return [ |