* Deploy script for deploying a working copy to the My Account production server */ use Cogeco\Build\Task; use Cogeco\Build\Task\CliTask; use Cogeco\Build\MyAccount\MyAccountTask; // Include the core of the build scripts and properties include_once __DIR__ . '/../../source/php/bootstrap.php'; // ********** // Parse script args - Use the build ID to identify many builds in the same script $buildId = 'uat'; if (isset($argv[1])) { if ($argv[1] === 'prod') { $buildId = 'prod'; } else { if ($argv[1] === 'uat') { $buildId = 'uat'; } else { if (strtolower($argv[1]) === '-help') { exit("Usage: {$argv[1]} [prod|uat]\n\n"); } } } } // ******************************* // Initial output Task::log("\n---------------------------------------\n"); Task::log("-------- Getting revision for My Account {$buildId}\n\n"); // *** // Prompt for user password, if it's not hardcoded CliTask::promptAccountPassword($cogecoAccount); Task::log('Revision: ' . MyAccountTask::getRemoteRevision($buildId === 'prod' ? $maoProdDir : $maoUatDir) . "\n\n");
/** * Prompt the user to select a working copy * @param string $promptText * @return mixed */ public static function promptWorkingCopy($promptText = 'Choose a working copy:') { $choices = array(); $workingCopies = Entity::getList('WorkingCopy'); foreach ($workingCopies as $index => $wc) { /** @var $wc \Cogeco\Build\Entity\WorkingCopy */ $choices[] = $wc->id; } $selection = CliTask::promptMultipleChoice($choices, $promptText); return $workingCopies[$selection]; }
// Start the build script // ******************************* Config::enableLogging(); // ******************** // *** Initial output // Task::log("\n---------------------------------------\n"); Task::log("-------- Sync repository\n\n"); // Prompt for user password, if it's not hardcoded CliTask::promptAccountPassword($cogecoAccount); // ******************** // Prompt user input // // Prompt user to input a local folder to sync $workingCopy = CliTask::promptRepo(); Task::log("You chose " . $workingCopy->getRepoUrl() . "\n\n"); // Prompt user to chose a remote folder to sync to $selectedDir = CliTask::promptDir(array($devDir, $dev2Dir, $uatDir, $uat2Dir, $uat3Dir, $preprodDir)); Task::log("You chose " . $selectedDir->getPath() . "\n\n"); CliTask::promptQuit('Continue? [y/n]: '); // ******************** // *** Checkout // SvnTask::checkoutClean($workingCopy); SvnTask::createManifestFile($workingCopy, FALSE, TRUE); // ******************** // Sync files and folders // $rsyncOptions = new RsyncOptions($workingCopy->dir, $selectedDir); $rsyncOptions->chmod('Du=rwx,Dg=rwx,Do=rwx,Fu=rw,Fg=rw,Fo=r')->excludesAppend(array('/dev/', '/db/')); FileSyncTask::sync($rsyncOptions);
use Cogeco\Build\Task\SvnTask; // Include the build script core include_once __DIR__ . '/../../bootstrap.php'; // ******************************* // Script configuration // ******************************* // ******************************* // Start the build script // ******************************* Config::enableLogging(); // ******************** // *** Initial output // Task::log("\n---------------------------------------\n"); Task::log("-------- Dump database\n\n"); // Prompt for user password, if it's not hardcoded CliTask::promptAccountPassword($cogecoAccount); // ******************** // Prompt user input // // Prepare a list of possible databases to dump $dbList = array($localPublicDb, $localPublicUBCDb, $localPublicPromo, $localPublicGBIncrease, $devPublicDb, $dev2PublicDb, $dev3PublicDb, $dev4PublicDb, $uatPublicDb, $preprodPublicDb, $prodPublicDb); // Prompt user to input a source database $sourceDb = CliTask::promptDatabase($dbList, 'Choose a database:'); Task::log("You chose " . $sourceDb->getDbName() . " on " . $sourceDb->getHost()->getHostname() . "\n\n"); if (($key = array_search($sourceDb, $dbList)) !== false) { unset($dbList[$key]); } // Dump DB to an sql script $tmpDumpFile = new File(SCRIPT_DB_DIR, $sourceDb->getHost()->getHostname() . '-' . $sourceDb->getDbName() . '-' . Config::get('datetime.slug') . '.sql'); MysqlTask::mysqlDump($sourceDb, $sourceDb->getDbName(), array(), $tmpDumpFile);