Skip to content

Instantly share code, notes, and snippets.

@beelbrecht
Created October 14, 2012 20:59
Show Gist options
  • Save beelbrecht/3889804 to your computer and use it in GitHub Desktop.
Save beelbrecht/3889804 to your computer and use it in GitHub Desktop.
This is an example of a simple deployment script using with the great TYPO3 Surf. You can use this script with TYPO3 Surf to deploy a simple static website.
<?php
// Create a simple workflow based on the predefined 'SimpleWorkflow'.
$workflow = new \TYPO3\Surf\Domain\Model\SimpleWorkflow();
// Define a custom task for smoketesting based on the 'httptest' task.
// Be sure, that the document root of next.example.org points to
// '[deploymentPath]/releases/next'
$smokeTestOptions = array(
'url' => 'http://next.example.org',
'remote' => FALSE,
'expectedStatus' => 200
);
$workflow->defineTask('yournamespace:smoketest', 'typo3.surf:test:httptest', $smokeTestOptions);
// Add the new defined task to the workflow 'test' stage.
$workflow->addTask('yournamespace:smoketest', 'test');
// Add the workflow to the deployment. The $deployment instance is created by Surf.
$deployment->setWorkflow($workflow);
// Create and configure your node / nodes (host / hosts).
$node = new \TYPO3\Surf\Domain\Model\Node('foobar');
$node->setHostname('example.org');
// If you don't use SSH-Keys to log into your remote host via SSH (as recommended),
// you have to to add the following line:
// $node->setOption('password', 'bar');
// But you don't want to have any passwords as string in your deployment script ;-)
$node->setOption('username', 'foo');
// Define your application and add it to your node.
$application = new \TYPO3\Surf\Application\BaseApplication('myCoolApp');
// The deployment path is not the document root!
// The document root has to be: '[deploymentPath]/releases/current'.
$application->setDeploymentPath('/path/to/your/app');
// Be sure, that your node has read-access to your git repository.
// In most cases, you can use the git- or https-protocol for public repositories or
// SSH to read from private repositories.
// Here is an example with the git protocol and a public repository.
$application->setOption('repositoryUrl', 'git://github.com/githubUsername/myCoolApp.git');
$application->addNode($node);
// Add the application to your deployment.
$deployment->addApplication($application);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment