$slack_channel_name = $secrets['slack_channel']; $slack_user_name = 'PerformanceTesting-with-LoadImpact'; $slack_user_icon = $secrets['live_url'] . '/wp-content/uploads/icons/loadimpact.png'; // If we are deploying to test, run a performace test if (defined('PANTHEON_ENVIRONMENT') && PANTHEON_ENVIRONMENT == 'test') { echo 'Starting a performance test on the test environment...' . "\n"; $text = 'Performance test has started. Doing a test of 50 virtual users for 3 minutes...'; $fields = array(array('title' => 'Site', 'value' => $_ENV['PANTHEON_SITE_NAME'], 'short' => 'true'), array('title' => 'Environment', 'value' => '<http://' . $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $_ENV['PANTHEON_SITE_NAME'] . '.pantheonsite.io|' . $_ENV['PANTHEON_ENVIRONMENT'] . '>', 'short' => 'true'), array('title' => 'By', 'value' => $_POST['user_email'], 'short' => 'true'), array('title' => 'Message', 'value' => $text, 'short' => 'false')); $attachment = array('fallback' => $text, 'color' => 'warning', 'fields' => $fields); _slack_tell($text, $slack_channel_name, $slack_user_name, $slack_user_icon, false, $attachment); $curl = curl_init(); $curl_options = array(CURLOPT_URL => 'https://api.loadimpact.com/v2/test-configs/' . $test_config_id . '/start', CURLOPT_USERPWD => $api_key . ':', CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1); curl_setopt_array($curl, $curl_options); $curl_response = json_decode(curl_exec($curl)); curl_close($curl); if (isset($curl_response->id)) { // Let's run a V3 Call to Get Public URL $curl = curl_init(); $curl_options = array(CURLOPT_URL => 'https://api.loadimpact.com/v3/test-runs/' . $curl_response->id . '/generate_public_url', CURLOPT_USERPWD => $api_key_v3 . ':', CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_RETURNTRANSFER => 1, CURLOPT_POST => 1); curl_setopt_array($curl, $curl_options); $curl_response = json_decode(curl_exec($curl)); curl_close($curl); echo 'Test results: ' . $curl_response->test_run->public_url . "\n"; $text = 'Visual regression test results: ' . $curl_response->test_run->public_url; $fields = array(array('title' => 'Site', 'value' => $_ENV['PANTHEON_SITE_NAME'], 'short' => 'true'), array('title' => 'Environment', 'value' => '<http://' . $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $_ENV['PANTHEON_SITE_NAME'] . '.pantheonsite.io|' . $_ENV['PANTHEON_ENVIRONMENT'] . '>', 'short' => 'true'), array('title' => 'By', 'value' => $_POST['user_email'], 'short' => 'true'), array('title' => 'Message', 'value' => $text, 'short' => 'false')); $attachment = array('fallback' => $text, 'color' => 'good', 'fields' => $fields); _slack_tell($text, $slack_channel_name, $slack_user_name, $slack_user_icon, false, $attachment); } else { echo 'There has been an error: ' . ucwords($curl_response->message) . "\n"; } }
$output = str_replace(' update', ' [update]', $output); $output = str_replace(' create', ' [create]', $output); $output = str_replace(' delete', ' [delete]', $output); $output = implode($output, "\n"); $output = rtrim($output); _slack_tell($output, $slack_channel_name, $slack_user_name, $slack_user_icon, '#A9A9A9'); } _slack_tell('Importation of WordPress WP-CFM Default Configuration on the ' . PANTHEON_ENVIRONMENT . ' environment is complete.', $slack_channel_name, $slack_user_name, $slack_user_icon); $path = $_SERVER['DOCUMENT_ROOT'] . '/private/config'; $files = scandir($path); $files = array_diff(scandir($path), array('.', '..')); foreach ($files as $file) { $file_parts = pathinfo($file); if ($file_parts['extension'] != 'json' || stripos($config_map, $file) !== FALSE) { continue; } _slack_tell('Importation of WordPress WP-CFM ' . $file . ' Configuration on the ' . PANTHEON_ENVIRONMENT . ' environment is starting...', $slack_channel_name, $slack_user_name, $slack_user_icon); exec('wp config pull ' . $config_name . ' 2>&1', $output); if (count($output) > 0) { $output = preg_replace('/\\s+/', ' ', array_slice($output, 1, -1)); $output = str_replace(' update', ' [update]', $output); $output = str_replace(' create', ' [create]', $output); $output = str_replace(' delete', ' [delete]', $output); $output = implode($output, "\n"); $output = rtrim($output); _slack_tell($output, $slack_channel_name, $slack_user_name, $slack_user_icon, '#A9A9A9'); } _slack_tell('Importation of WordPress WP-CFM ' . $file . ' Configuration on the ' . PANTHEON_ENVIRONMENT . ' environment is complete.', $slack_channel_name, $slack_user_name, $slack_user_icon); } exec('wp cache flush'); print "\n==== Config Import Complete ====\n";
<?php // Secrets helper function require_once dirname(__FILE__) . '/secrets_helper.php'; // Load Slack helper functions require_once dirname(__FILE__) . '/slack_helper.php'; $secrets = _get_secrets(array('slack_channel', 'live_url')); $slack_user_icon = $secrets['live_url'] . 'wp-content/uploads/icons/git.png'; if (isset($_POST['wf_type']) && $_POST['wf_type'] == 'sync_code') { // Get the committer, hash, and message for the most recent commit. $committer = `git log -1 --pretty=%cn`; $email = `git log -1 --pretty=%ce`; $message = `git log -1 --pretty=%B`; $hash = `git log -1 --pretty=%h`; // Setup the Text $text = 'Git commit (' . rtrim($hash) . ') with message "' . rtrim($message) . '"'; $fields = array(array('title' => 'Site', 'value' => $_ENV['PANTHEON_SITE_NAME'], 'short' => 'true'), array('title' => 'Environment', 'value' => '<http://' . $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $_ENV['PANTHEON_SITE_NAME'] . '.pantheonsite.io|' . $_ENV['PANTHEON_ENVIRONMENT'] . '>', 'short' => 'true'), array('title' => 'By', 'value' => $committer . ' (' . $email . ')', 'short' => 'true'), array('title' => 'Message', 'value' => $text, 'short' => 'false')); $attachment = array('fallback' => $text, 'color' => '#EFD01B', 'fields' => $fields); _slack_tell($text, $secrets['slack_channel'], 'Git-on-Pantheon', $slack_user_icon, false, $attachment); }