Skip to content

Instantly share code, notes, and snippets.

@jacobsenj
Last active October 20, 2016 08:36
Show Gist options
  • Save jacobsenj/9c21bc64a0236dd2a56f to your computer and use it in GitHub Desktop.
Save jacobsenj/9c21bc64a0236dd2a56f to your computer and use it in GitHub Desktop.
<?php
/**
* @var \TYPO3\Surf\Domain\Model\Deployment $deployment
* @var \TYPO3\Surf\Domain\Model\SimpleWorkflow $workflow
*/
$domain = '';
$server = '';
$user = '';
$branch = 'master';
// APPLICATION
$application = new \TYPO3\Surf\Application\TYPO3\CMS;
$application->setOption('projectName', 'Projectname');
$application->setOption('repositoryUrl', 'git@gitlab:example/example-repository.git');
$application->setOption('packageMethod', 'git');
$application->setOption('transferMethod', 'rsync');
$application->setOption('updateMethod', NULL);
$application->setOption('keepReleases', 5);
// rsync excludes
$rsyncFlags = array(
'-az',
'--recursive',
'--delete',
'--delete-excluded',
"--exclude '.git*'",
'--exclude .phpstorm.meta.php',
'--exclude .svn',
'--exclude /.bowerrc',
'--exclude /.bundle',
'--exclude /bower.json',
'--exclude /config',
'--exclude /lib',
'--exclude /logs',
'--exclude /patches',
'--exclude /puphpet',
'--exclude /scripts',
'--exclude /sql',
'--exclude AdditionalConfiguration.php.dist',
'--exclude Capfile',
'--exclude Gemfile*',
'--exclude Rakefile',
"--exclude '*.md'",
'--exclude livediff.sh',
'--exclude phpunit.xml.dist',
);
$application->setOption('rsyncFlags', implode(' ', $rsyncFlags));
$application->setOption('branch', $branch);
$application->setOption('typo3.surf:gitCheckout[branch]', $branch);
// in our case the deployable sources are in /src
$application->setOption('applicationRootDirectory', 'src');
$application->setDeploymentPath('/path/to/deploy/to');
$application->setSymlinks(array(
'src/typo3_src' => $application->getSharedPath() . '/typo3_src',
'src/typo3conf/AdditionalConfiguration.php' => $application->getSharedPath() . '/typo3conf/AdditionalConfiguration.php',
'src/typo3' => 'typo3_src/typo3',
'src/index.php' => 'typo3_src/index.php',
));
// WORKFLOW
$workflow = new \TYPO3\Surf\Domain\Model\SimpleWorkflow;
// NODES
$node = new \TYPO3\Surf\Domain\Model\Node($server);
$node->setHostname($server);
$node->setOption('username', $user);
$application->addNode($node);
// REMOVE TASKS
$deployment->onInitialize(function () use ($workflow, $application) {
//$workflow->removeTask('task/to/be/removed');
});
// DEPLOYMENT
$deployment->setWorkflow($workflow);
$deployment->addApplication($application);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment