@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | namespace Deployer; |
8 | 8 | |
9 | 9 | // Get path to bin |
10 | -set('bin/crontab', function () { |
|
10 | +set('bin/crontab', function() { |
|
11 | 11 | return run('which crontab'); |
12 | 12 | }); |
13 | 13 | |
14 | 14 | desc('Load crontab'); |
15 | -task('crontab:load', function () { |
|
15 | +task('crontab:load', function() { |
|
16 | 16 | set('crontab:all', []); |
17 | 17 | |
18 | 18 | // Crontab is empty |
19 | - if (!test ("[ -f '/var/spool/cron/{{user}}' ]")) { |
|
19 | + if (!test("[ -f '/var/spool/cron/{{user}}' ]")) { |
|
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | - $cronData = run ("{{bin/crontab}} -l"); |
|
24 | - $cronLines = explode (PHP_EOL, $cronData); |
|
23 | + $cronData = run("{{bin/crontab}} -l"); |
|
24 | + $cronLines = explode(PHP_EOL, $cronData); |
|
25 | 25 | |
26 | 26 | $currentTasks = []; |
27 | 27 | foreach ($cronLines as $cronLine) { |
28 | 28 | $jobData = parseJob($cronLine); |
29 | - if (is_null ($jobData)) { |
|
29 | + if (is_null($jobData)) { |
|
30 | 30 | continue; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $currentTasks[$jobData['ckey']] = $jobData; |
34 | 34 | } |
35 | 35 | |
36 | - set ('crontab:all', $currentTasks); |
|
36 | + set('crontab:all', $currentTasks); |
|
37 | 37 | }); |
38 | 38 | |
39 | 39 | desc('Sync crontab jobs'); |
40 | -task('crontab:sync', function () { |
|
40 | +task('crontab:sync', function() { |
|
41 | 41 | $syncJobs = get('crontab:jobs', []); |
42 | 42 | |
43 | - if (count ($syncJobs) == 0) { |
|
43 | + if (count($syncJobs) == 0) { |
|
44 | 44 | writeln("Nothing to sync - configure crontab:jobs"); |
45 | 45 | return; |
46 | 46 | } |
@@ -52,18 +52,18 @@ discard block |
||
52 | 52 | foreach ($syncJobs as $syncJob) { |
53 | 53 | $syncJobData = parseJob($syncJob); |
54 | 54 | |
55 | - if (is_null ($syncJobData)) { |
|
55 | + if (is_null($syncJobData)) { |
|
56 | 56 | continue; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $cronJobData = $cronJobs[$syncJobData['ckey']] ?? NULL; |
60 | 60 | |
61 | - if (!is_null ($cronJobData) && $cronJobData['skey'] == $syncJobData['skey']) { |
|
61 | + if (!is_null($cronJobData) && $cronJobData['skey'] == $syncJobData['skey']) { |
|
62 | 62 | // Job is exists and correct |
63 | 63 | writeLn($syncJobData['cmd'] . ': <fg=green;options=bold>OK</>'); |
64 | 64 | } |
65 | 65 | else { |
66 | - if (is_null ($cronJobData)) { |
|
66 | + if (is_null($cronJobData)) { |
|
67 | 67 | writeLn($syncJobData['cmd'] . ': <fg=yellow;options=bold>NEW</>'); |
68 | 68 | } |
69 | 69 | else { |
@@ -74,38 +74,38 @@ discard block |
||
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - if (test ("[ -f '/tmp/crontab_save' ]")) { |
|
78 | - run ("unlink '/tmp/crontab_save'"); |
|
77 | + if (test("[ -f '/tmp/crontab_save' ]")) { |
|
78 | + run("unlink '/tmp/crontab_save'"); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | foreach ($cronJobs as $cronJob) { |
82 | 82 | $jobString = $cronJob['minute'] . ' ' . $cronJob['hour'] . ' ' . $cronJob['day'] . ' ' . $cronJob['month'] . ' ' . $cronJob['weekday'] . ' ' . $cronJob['cmd']; |
83 | - run ("echo '" . $jobString . "' >> '/tmp/crontab_save'"); |
|
83 | + run("echo '" . $jobString . "' >> '/tmp/crontab_save'"); |
|
84 | 84 | } |
85 | 85 | |
86 | - run ("{{bin/crontab}} /tmp/crontab_save"); |
|
87 | - run ('unlink /tmp/crontab_save'); |
|
86 | + run("{{bin/crontab}} /tmp/crontab_save"); |
|
87 | + run('unlink /tmp/crontab_save'); |
|
88 | 88 | }); |
89 | 89 | |
90 | 90 | |
91 | -function parseJob ($job) { |
|
91 | +function parseJob($job) { |
|
92 | 92 | if (!is_string($job)) { |
93 | 93 | return NULL; |
94 | 94 | } |
95 | 95 | |
96 | - if (substr ($job, 0, 1) == '#') { |
|
96 | + if (substr($job, 0, 1) == '#') { |
|
97 | 97 | return NULL; |
98 | 98 | } |
99 | 99 | |
100 | - $jobData = explode (' ', $job, 6); |
|
100 | + $jobData = explode(' ', $job, 6); |
|
101 | 101 | |
102 | - if (count ($jobData) != 6) { |
|
102 | + if (count($jobData) != 6) { |
|
103 | 103 | return NULL; |
104 | 104 | } |
105 | 105 | |
106 | 106 | return [ |
107 | - 'skey' => md5 ($job), |
|
108 | - 'ckey' => md5 ($jobData['5']), |
|
107 | + 'skey' => md5($job), |
|
108 | + 'ckey' => md5($jobData['5']), |
|
109 | 109 | 'minute' => $jobData['0'], |
110 | 110 | 'hour' => $jobData['1'], |
111 | 111 | 'day' => $jobData['2'], |
@@ -61,12 +61,10 @@ |
||
61 | 61 | if (!is_null ($cronJobData) && $cronJobData['skey'] == $syncJobData['skey']) { |
62 | 62 | // Job is exists and correct |
63 | 63 | writeLn($syncJobData['cmd'] . ': <fg=green;options=bold>OK</>'); |
64 | - } |
|
65 | - else { |
|
64 | + } else { |
|
66 | 65 | if (is_null ($cronJobData)) { |
67 | 66 | writeLn($syncJobData['cmd'] . ': <fg=yellow;options=bold>NEW</>'); |
68 | - } |
|
69 | - else { |
|
67 | + } else { |
|
70 | 68 | writeLn($syncJobData['cmd'] . ': <fg=red;options=bold>FIX</>'); |
71 | 69 | } |
72 | 70 |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | throw new \Exception('Please, configure "telegram_chat_id" parameter.'); |
26 | 26 | }); |
27 | 27 | set('telegram_url', function () { |
28 | - return 'https://api.telegram.org/bot' . get('telegram_token') . '/sendmessage'; |
|
28 | + return 'https://api.telegram.org/bot' . get('telegram_token') . '/sendmessage'; |
|
29 | 29 | }); |
30 | 30 | |
31 | 31 | // Deploy message |
@@ -65,61 +65,61 @@ discard block |
||
65 | 65 | ->shallow() |
66 | 66 | ->hidden(); |
67 | 67 | |
68 | - desc('Notifying Telegram about deploy finish'); |
|
69 | - task('telegram:notify:success', function () { |
|
70 | - if (!get('telegram_token', false)) { |
|
71 | - return; |
|
72 | - } |
|
68 | + desc('Notifying Telegram about deploy finish'); |
|
69 | + task('telegram:notify:success', function () { |
|
70 | + if (!get('telegram_token', false)) { |
|
71 | + return; |
|
72 | + } |
|
73 | 73 | |
74 | - if (!get('telegram_chat_id', false)) { |
|
75 | - return; |
|
76 | - } |
|
74 | + if (!get('telegram_chat_id', false)) { |
|
75 | + return; |
|
76 | + } |
|
77 | 77 | |
78 | - $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
79 | - Array ( |
|
80 | - 'chat_id' => get('telegram_chat_id'), |
|
81 | - 'text' => get('telegram_success_text'), |
|
82 | - 'parse_mode' => 'Markdown', |
|
83 | - ) |
|
84 | - ); |
|
78 | + $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
79 | + Array ( |
|
80 | + 'chat_id' => get('telegram_chat_id'), |
|
81 | + 'text' => get('telegram_success_text'), |
|
82 | + 'parse_mode' => 'Markdown', |
|
83 | + ) |
|
84 | + ); |
|
85 | 85 | |
86 | - $httpie = Httpie::get($telegramUrl); |
|
86 | + $httpie = Httpie::get($telegramUrl); |
|
87 | 87 | |
88 | - if (get('telegram_proxy', '') !== '') { |
|
89 | - $httpie = $httpie->setopt(CURLOPT_PROXY, get('telegram_proxy')); |
|
90 | - } |
|
88 | + if (get('telegram_proxy', '') !== '') { |
|
89 | + $httpie = $httpie->setopt(CURLOPT_PROXY, get('telegram_proxy')); |
|
90 | + } |
|
91 | 91 | |
92 | - $httpie->send(); |
|
92 | + $httpie->send(); |
|
93 | 93 | }) |
94 | 94 | ->once() |
95 | 95 | ->shallow() |
96 | 96 | ->hidden(); |
97 | 97 | |
98 | - desc('Notifying Telegram about deploy failure'); |
|
99 | - task('telegram:notify:failure', function () { |
|
100 | - if (!get('telegram_token', false)) { |
|
101 | - return; |
|
102 | - } |
|
98 | + desc('Notifying Telegram about deploy failure'); |
|
99 | + task('telegram:notify:failure', function () { |
|
100 | + if (!get('telegram_token', false)) { |
|
101 | + return; |
|
102 | + } |
|
103 | 103 | |
104 | - if (!get('telegram_chat_id', false)) { |
|
105 | - return; |
|
106 | - } |
|
104 | + if (!get('telegram_chat_id', false)) { |
|
105 | + return; |
|
106 | + } |
|
107 | 107 | |
108 | - $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
109 | - Array ( |
|
110 | - 'chat_id' => get('telegram_chat_id'), |
|
111 | - 'text' => get('telegram_failure_text'), |
|
112 | - 'parse_mode' => 'Markdown', |
|
113 | - ) |
|
114 | - ); |
|
108 | + $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
109 | + Array ( |
|
110 | + 'chat_id' => get('telegram_chat_id'), |
|
111 | + 'text' => get('telegram_failure_text'), |
|
112 | + 'parse_mode' => 'Markdown', |
|
113 | + ) |
|
114 | + ); |
|
115 | 115 | |
116 | - $httpie = Httpie::get($telegramUrl); |
|
116 | + $httpie = Httpie::get($telegramUrl); |
|
117 | 117 | |
118 | - if (get('telegram_proxy', '') !== '') { |
|
119 | - $httpie = $httpie->setopt(CURLOPT_PROXY, get('telegram_proxy')); |
|
120 | - } |
|
118 | + if (get('telegram_proxy', '') !== '') { |
|
119 | + $httpie = $httpie->setopt(CURLOPT_PROXY, get('telegram_proxy')); |
|
120 | + } |
|
121 | 121 | |
122 | - $httpie->send(); |
|
122 | + $httpie->send(); |
|
123 | 123 | }) |
124 | 124 | ->once() |
125 | 125 | ->shallow() |
@@ -13,18 +13,18 @@ discard block |
||
13 | 13 | use Deployer\Utility\Httpie; |
14 | 14 | |
15 | 15 | // Title of project |
16 | -set('telegram_title', function () { |
|
16 | +set('telegram_title', function() { |
|
17 | 17 | return get('application', 'Project'); |
18 | 18 | }); |
19 | 19 | |
20 | 20 | // Telegram settings |
21 | -set('telegram_token', function () { |
|
21 | +set('telegram_token', function() { |
|
22 | 22 | throw new \Exception('Please, configure "telegram_token" parameter.'); |
23 | 23 | }); |
24 | -set('telegram_chat_id', function () { |
|
24 | +set('telegram_chat_id', function() { |
|
25 | 25 | throw new \Exception('Please, configure "telegram_chat_id" parameter.'); |
26 | 26 | }); |
27 | -set('telegram_url', function () { |
|
27 | +set('telegram_url', function() { |
|
28 | 28 | return 'https://api.telegram.org/bot' . get('telegram_token') . '/sendmessage'; |
29 | 29 | }); |
30 | 30 | |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | desc('Notifying Telegram'); |
38 | 38 | |
39 | -task('telegram:notify', function () { |
|
39 | +task('telegram:notify', function() { |
|
40 | 40 | if (!get('telegram_token', false)) { |
41 | 41 | return; |
42 | 42 | } |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | return; |
46 | 46 | } |
47 | 47 | |
48 | - $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
49 | - Array ( |
|
48 | + $telegramUrl = get('telegram_url') . '?' . http_build_query( |
|
49 | + Array( |
|
50 | 50 | 'chat_id' => get('telegram_chat_id'), |
51 | 51 | 'text' => get('telegram_text'), |
52 | 52 | 'parse_mode' => 'Markdown', |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | ->hidden(); |
67 | 67 | |
68 | 68 | desc('Notifying Telegram about deploy finish'); |
69 | - task('telegram:notify:success', function () { |
|
69 | + task('telegram:notify:success', function() { |
|
70 | 70 | if (!get('telegram_token', false)) { |
71 | 71 | return; |
72 | 72 | } |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | return; |
76 | 76 | } |
77 | 77 | |
78 | - $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
79 | - Array ( |
|
78 | + $telegramUrl = get('telegram_url') . '?' . http_build_query( |
|
79 | + Array( |
|
80 | 80 | 'chat_id' => get('telegram_chat_id'), |
81 | 81 | 'text' => get('telegram_success_text'), |
82 | 82 | 'parse_mode' => 'Markdown', |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | ->hidden(); |
97 | 97 | |
98 | 98 | desc('Notifying Telegram about deploy failure'); |
99 | - task('telegram:notify:failure', function () { |
|
99 | + task('telegram:notify:failure', function() { |
|
100 | 100 | if (!get('telegram_token', false)) { |
101 | 101 | return; |
102 | 102 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | return; |
106 | 106 | } |
107 | 107 | |
108 | - $telegramUrl = get('telegram_url') . '?' . http_build_query ( |
|
109 | - Array ( |
|
108 | + $telegramUrl = get('telegram_url') . '?' . http_build_query( |
|
109 | + Array( |
|
110 | 110 | 'chat_id' => get('telegram_chat_id'), |
111 | 111 | 'text' => get('telegram_failure_text'), |
112 | 112 | 'parse_mode' => 'Markdown', |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | use Deployer\Utility\Httpie; |
30 | 30 | |
31 | 31 | // Title of project |
32 | -set('teams_title', function () { |
|
32 | +set('teams_title', function() { |
|
33 | 33 | return get('application', 'Project'); |
34 | 34 | }); |
35 | 35 | |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | set('teams_failure_color', '#ff0909'); |
45 | 45 | |
46 | 46 | desc('Notifying Teams'); |
47 | -task('teams:notify', function () { |
|
47 | +task('teams:notify', function() { |
|
48 | 48 | if (!get('teams_webhook', false)) { |
49 | 49 | return; |
50 | 50 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | ->hidden(); |
60 | 60 | |
61 | 61 | desc('Notifying Teams about deploy finish'); |
62 | -task('teams:notify:success', function () { |
|
62 | +task('teams:notify:success', function() { |
|
63 | 63 | if (!get('teams_webhook', false)) { |
64 | 64 | return; |
65 | 65 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | ->hidden(); |
75 | 75 | |
76 | 76 | desc('Notifying Teams about deploy failure'); |
77 | -task('teams:notify:failure', function () { |
|
77 | +task('teams:notify:failure', function() { |
|
78 | 78 | if (!get('teams_webhook', false)) { |
79 | 79 | return; |
80 | 80 | } |
@@ -11,7 +11,7 @@ |
||
11 | 11 | |
12 | 12 | |
13 | 13 | desc('Create Grafana annotation of deployment'); |
14 | -task('grafana:annotation', function () { |
|
14 | +task('grafana:annotation', function() { |
|
15 | 15 | $defaultConfig = [ |
16 | 16 | 'url' => null, |
17 | 17 | 'token' => null, |
@@ -10,7 +10,7 @@ |
||
10 | 10 | use Deployer\Utility\Httpie; |
11 | 11 | |
12 | 12 | desc('Notifying Raygun of deployment'); |
13 | -task('raygun:notify', function () { |
|
13 | +task('raygun:notify', function() { |
|
14 | 14 | $data = [ |
15 | 15 | 'apiKey' => get('raygun_api_key'), |
16 | 16 | 'version' => get('raygun_version'), |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | set('yammer_url', 'https://www.yammer.com/api/v1/messages.json'); |
13 | 13 | |
14 | 14 | // Title of project |
15 | -set('yammer_title', function () { |
|
15 | +set('yammer_title', function() { |
|
16 | 16 | return get('application', 'Project'); |
17 | 17 | }); |
18 | 18 | |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | set('yammer_failure_body', 'Deploy to <strong>{{target}}</strong> failed'); |
23 | 23 | |
24 | 24 | desc('Notifying Yammer'); |
25 | -task('yammer:notify', function () { |
|
25 | +task('yammer:notify', function() { |
|
26 | 26 | $params = [ |
27 | 27 | 'is_rich_text' => 'true', |
28 | 28 | 'message_type' => 'announcement', |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | ->hidden(); |
43 | 43 | |
44 | 44 | desc('Notifying Yammer about deploy finish'); |
45 | -task('yammer:notify:success', function () { |
|
45 | +task('yammer:notify:success', function() { |
|
46 | 46 | $params = [ |
47 | 47 | 'is_rich_text' => 'true', |
48 | 48 | 'message_type' => 'announcement', |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | ->hidden(); |
63 | 63 | |
64 | 64 | desc('Notifying Yammer about deploy failure'); |
65 | -task('yammer:notify:failure', function () { |
|
65 | +task('yammer:notify:failure', function() { |
|
66 | 66 | $params = [ |
67 | 67 | 'is_rich_text' => 'true', |
68 | 68 | 'message_type' => 'announcement', |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | namespace Deployer; |
10 | 10 | |
11 | -set('bin/yarn', function () { |
|
11 | +set('bin/yarn', function() { |
|
12 | 12 | return run('which yarn'); |
13 | 13 | }); |
14 | 14 | |
15 | 15 | desc('Install Yarn packages'); |
16 | -task('yarn:install', function () { |
|
16 | +task('yarn:install', function() { |
|
17 | 17 | if (has('previous_release')) { |
18 | 18 | if (test('[ -d {{previous_release}}/node_modules ]')) { |
19 | 19 | run('cp -R {{previous_release}}/node_modules {{release_path}}'); |
@@ -12,7 +12,7 @@ |
||
12 | 12 | set('rollbar_comment', '_{{user}}_ deploying `{{branch}}` to *{{target}}*'); |
13 | 13 | |
14 | 14 | desc('Notifying Rollbar of deployment'); |
15 | -task('rollbar:notify', function () { |
|
15 | +task('rollbar:notify', function() { |
|
16 | 16 | if (!get('rollbar_token', false)) { |
17 | 17 | return; |
18 | 18 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | set('workplace_edit_post', false); |
19 | 19 | |
20 | 20 | desc('Notifying Workplace'); |
21 | -task('workplace:notify', function () { |
|
21 | +task('workplace:notify', function() { |
|
22 | 22 | if (!get('workplace_webhook', false)) { |
23 | 23 | return; |
24 | 24 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | ->hidden(); |
44 | 44 | |
45 | 45 | desc('Notifying Workplace about deploy finish'); |
46 | -task('workplace:notify:success', function () { |
|
46 | +task('workplace:notify:success', function() { |
|
47 | 47 | if (!get('workplace_webhook', false)) { |
48 | 48 | return; |
49 | 49 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | ->hidden(); |
56 | 56 | |
57 | 57 | desc('Notifying Workplace about deploy failure'); |
58 | -task('workplace:notify:failure', function () { |
|
58 | +task('workplace:notify:failure', function() { |
|
59 | 59 | if (!get('workplace_webhook', false)) { |
60 | 60 | return; |
61 | 61 | } |