public function execute()
{
// Check if server is ready for deployment
if (!$this->isSetup()) {
$this->explainer->error('Server is not ready, running Setup task');
$this->executeTask('Setup');
}
// Check if local is ready for deployment
if (!$this->executeTask('Primer')) {
return $this->halt('Project is not ready for deploy. You were almost fired.');
}
// Setup the new release
$release = $this->releasesManager->getNextRelease();
// Create release and set it up
$this->steps()->executeTask('CreateRelease');
$this->steps()->executeTask('Dependencies');
if ($this->getOption('tests')) {
$this->steps()->executeTask('Test');
}
// Synchronize shared folders and files
$this->steps()->syncSharedFolders();
// Create release and set permissions
$this->steps()->setApplicationPermissions();
// Run migrations
if ($this->getOption('migrate') || $this->getOption('seed')) {
$this->steps()->executeTask('Migrate');
}
// Run before-symlink events
$this->steps()->fireEvent('before-symlink');
// Update symlink
$this->steps()->updateSymlink();
// Run the steps until one fails
if (!$this->runSteps()) {
return $this->halt();
}
$this->releasesManager->markReleaseAsValid($release);
return $this->explainer->line('Successfully deployed release ' . $release);
}