Last active
September 13, 2018 04:02
-
-
Save Sebobo/4deda266a6367d75d80033297dac2424 to your computer and use it in GitHub Desktop.
TYPO3 v8 surf example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
stages: | |
- build | |
- deploy | |
variables: | |
COMPOSER_PROCESS_TIMEOUT: "1200" | |
NODE_ENV: "production" | |
cache: | |
key: "$CI_BUILD_REF_NAME" | |
paths: | |
- cache_*.tar | |
build: | |
stage: build | |
script: composer install | |
deploy-staging: | |
stage: deploy | |
script: ./surf.phar deploy staging --verbose | |
only: | |
- master | |
deploy-production: | |
stage: deploy | |
script: ./surf.phar deploy production --verbose | |
only: | |
- tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use TYPO3\Flow\Utility\Files; | |
/** @var $deployment TYPO3\Surf\Domain\Model\Deployment "injected" into this script from Surf */ | |
$baseUrl = 'https://www.example.org/'; | |
$hostname = 'www.example.org'; | |
$deploymentPath = '/var/www'; | |
$username = 'foo'; | |
$repository = '[email protected]:foo/bar.git'; | |
$context = 'Production/Staging'; | |
$nodename = 'exampleorg-staging'; | |
$node = new TYPO3\Surf\Domain\Model\Node($nodename); | |
$node | |
->setHostname($hostname) | |
->setOption('username', $username); | |
$application = new TYPO3\Surf\Application\TYPO3\CMS($nodename); | |
$application | |
->setOption('applicationWebDirectory', 'web') | |
->setOption('TYPO3\\Surf\\Task\\Php\\WebOpcacheResetCreateScriptTask[scriptBasePath]', Files::concatenatePaths(array($deployment->getWorkspacePath($application), 'web'))) | |
->setOption('TYPO3\\Surf\\Task\\TYPO3\\CMS\\SymlinkDataTask[applicationRootDirectory]', 'web') | |
->setOption('keepReleases', 3) | |
->setOption('composerCommandPath', 'composer') | |
->setOption('updateMethod', null) | |
->setOption('repositoryUrl', $repository) | |
->setOption('baseUrl', $baseUrl) | |
->setContext($context) | |
->setDeploymentPath($deploymentPath) | |
->addNode($node); | |
if (getenv('GIT_COMMIT')) { | |
$application->setOption('sha1', getenv('GIT_COMMIT')); | |
} else if (getenv('GIT_BRANCH')) { | |
$application->setOption('branch', getenv('GIT_BRANCH')); | |
} | |
$deployment->addApplication($application); | |
$deployment->onInitialize(function() use ($deployment) { | |
// Delete directories task currently needed, because of web folder in TYPO3 v8 via composer | |
// This can be removed when all Surf tasks and typo3console can handle the web folder | |
$deployment->getWorkflow() | |
->beforeStage('transfer', 'TYPO3\\Surf\\Task\\Php\\WebOpcacheResetCreateScriptTask') | |
->afterStage('switch', 'TYPO3\\Surf\\Task\\Php\\WebOpcacheResetExecuteTask') | |
->removeTask('TYPO3\\Surf\\Task\\TYPO3\\CMS\\CreatePackageStatesTask') | |
->defineTask('pt:DeleteDirectoriesTask', 'TYPO3\\Surf\\Task\\ShellTask', [ | |
'command' => 'rm -rf {releasePath}/web/fileadmin {releasePath}/web/uploads' | |
]) | |
->beforeTask('TYPO3\\Surf\\Task\\TYPO3\\CMS\\SymlinkDataTask', 'pt:DeleteDirectoriesTask'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment