Skip to content

Commit

Permalink
10.1.4
Browse files Browse the repository at this point in the history
10.1.4
  • Loading branch information
joegl authored Mar 6, 2024
2 parents e930da0 + 9de247b commit 4964ddc
Show file tree
Hide file tree
Showing 25 changed files with 595 additions and 724 deletions.
38 changes: 35 additions & 3 deletions blt/src/Blt/Plugin/Commands/HsCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class HsCommands extends BltTasks {
*
* @aliases humsci:post-code-update
*/
public function postCodeDeployUpdate() {
public function postCodeDeployUpdate($target_env, $deployed_tag) {
$sites = $this->getConfigValue('multisites');
$parallel_executions = 10;
$parallel_executions = (int) getenv('UPDATE_PARALLEL_PROCESSES') ?: 10;

$site_chunks = array_chunk($sites, ceil(count($sites) / $parallel_executions));
$commands = [];
foreach ($site_chunks as $sites) {
Expand All @@ -50,11 +51,42 @@ public function postCodeDeployUpdate() {
$failed[] = $site;
}
}
unlink(sys_get_temp_dir() . '/update-report.txt');

$this->yell(sprintf('Updated %s sites successfully.', count($success)), 100);

if ($failed) {
$this->yell(sprintf("Update failed for the following sites:\n%s", implode("\n", $failed)), 100, 'red');

if (in_array($target_env, ['prod', 'test'])) {
$count = count($failed);
$this->sendSlackNotification("A new deployment has been made to *$target_env* using *$deployed_tag*.\n\n*$count* sites failed to update.");
}
throw new \Exception('Failed update');
}
unlink(sys_get_temp_dir() . '/update-report.txt');

if (in_array($target_env, ['prod', 'test'])) {
$this->sendSlackNotification("A new deployment has been made to *$target_env* using *$deployed_tag*.");
}
}

/**
* Send out a slack notification.
*
* @param string $message
* Slack message.
*/
protected function sendSlackNotification(string $message) {
$client = new Client();
$client->post(getenv('SLACK_NOTIFICATION_URL'), [
'form_params' => [
'payload' => json_encode([
'username' => 'Acquia Cloud',
'text' => $message,
'icon_emoji' => 'information_source',
]),
],
]);
}

/**
Expand Down
Loading

0 comments on commit 4964ddc

Please sign in to comment.