Skip to content

Instantly share code, notes, and snippets.

@DavidSporer
Last active August 29, 2015 14:26
Show Gist options
  • Save DavidSporer/91ead27e2265af1081a6 to your computer and use it in GitHub Desktop.
Save DavidSporer/91ead27e2265af1081a6 to your computer and use it in GitHub Desktop.
<?php
use \TYPO3\Surf\Domain\Model\Node;
use \TYPO3\Surf\Domain\Model\SimpleWorkflow;
$application = new \Famelo\Surf\SharedHosting\Application\Flow();
$workflow = new SimpleWorkflow();
/* ---------------------------------------------------------------
*
* DEFINE GENERAL SETTINGS - Start
*
* ---------------------------------------------------------------
*/
// path where the Surf folders are created on the target servers
$application->setDeploymentPath('/html/example-live');
$application->setOption('repositoryUrl', '[email protected]:username/my.repository.git');
// checkout master branch
$application->setOption('branch', 'master');
// path to composer on the current machine
$application->setOption('composerCommandPath', '/usr/local/bin/composer');
$application->setOption('transferMethod', 'rsync');
$application->setOption('packageMethod', 'git');
$application->setOption('updateMethod', NULL);
$application->setOption('keepReleases', 3);
$application->setHosting('Mittwald');
/* ---------------------------------------------------------------
*
* DEFINE GENERAL SETTINGS - End
*
* ---------------------------------------------------------------
*/
/* ---------------------------------------------------------------
*
* DEFINE TARGET SERVER - Start
*
* ---------------------------------------------------------------
*/
$node = new Node('my-node-name');
$node->setHostname('example.de');
$node->setOption('username', 'myUsername');
/* ---------------------------------------------------------------
*
* DEFINE TARGET SERVER - End
*
* ---------------------------------------------------------------
*/
/* ---------------------------------------------------------------
*
* CUSTOM COMMANDS - Start
* - add context and pkpass type to .htaccess file
* - flush cache
* - warmup cache
*
* ---------------------------------------------------------------
*/
// Add context and pkpass type to .htaccess
$editHtaccessCommandOptions = array(
'command' => 'echo -e "\nSetEnv FLOW_CONTEXT Production \n\nAddType application/vnd.apple.pkpass .pkpass\n\n" >> {releasePath}/Web/.htaccess'
);
$workflow->defineTask('brainswarm.example:editHtaccess', 'typo3.surf:shell', $editHtaccessCommandOptions);
$workflow->addTask('brainswarm.example:editHtaccess', 'finalize');
// flush cache after everything is ready
$workflow->defineTask('brainswarm.example:cacheFlush',
'typo3.surf:shell',
array('command' => 'cd {releasePath} && FLOW_CONTEXT=Production ./flow flow:cache:flush')
);
// warmup cache to make everything prepared for go-live
$workflow->defineTask('brainswarm.example:cacheWarmup',
'typo3.surf:shell',
array('command' => 'cd {releasePath} && FLOW_CONTEXT=Production ./flow flow:cache:warmup')
);
// add cache flush and warmup task to finalize stage because otherwise smoke tests won't be able to run.
$workflow->addTask(array(
'brainswarm.example:cacheFlush',
'brainswarm.example:cacheWarmup'
), 'finalize');
/* ---------------------------------------------------------------
*
* CUSTOM COMMANDS - End
*
* ---------------------------------------------------------------
*/
/* ---------------------------------------------------------------
*
* SMOKE TESTS - Start
*
* ---------------------------------------------------------------
*/
$smokeTestOptions = array(
'url' => 'http://portal-next.example.de',
'remote' => TRUE,
'expectedStatus' => 200
);
$workflow->defineTask('brainswarm.example:smoketest-startpage', 'typo3.surf:test:httptest', $smokeTestOptions);
$workflow->addTask('brainswarm.example:smoketest-startpage', 'test', $application);
$smokeTestOptions = array(
'url' => 'http://portal-next.example.de/login',
'remote' => TRUE,
'expectedStatus' => 200
);
$workflow->defineTask('brainswarm.example:smoketest-login', 'typo3.surf:test:httptest', $smokeTestOptions);
$workflow->addTask('brainswarm.example:smoketest-login', 'test', $application);
/* ---------------------------------------------------------------
*
* SMOKE TESTS - End
*
* ---------------------------------------------------------------
*/
$deployment->setWorkflow($workflow);
$application->addNode($node);
$deployment->addApplication($application);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment