This repository has been archived by the owner on Sep 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 217
/
Deploy.php
103 lines (84 loc) · 2.71 KB
/
Deploy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
/*
* This file is part of Rocketeer
*
* (c) Maxime Fabre <ehtnam6@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Rocketeer\Tasks;
use Rocketeer\Abstracts\AbstractTask;
/**
* Deploy the website.
*
* @author Maxime Fabre <ehtnam6@gmail.com>
*/
class Deploy extends AbstractTask
{
/**
* The console command description.
*
* @type string
*/
protected $description = 'Deploys the website';
/**
* Run the task.
*
* @return bool|null
*/
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');
}
// Create release and set permissions
$this->steps()->setApplicationPermissions();
// Run migrations
if ($this->getOption('migrate') || $this->getOption('seed')) {
$this->steps()->executeTask('Migrate');
}
// Synchronize shared folders and files
$this->steps()->syncSharedFolders();
// 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);
}
////////////////////////////////////////////////////////////////////
/////////////////////////////// HELPERS ////////////////////////////
////////////////////////////////////////////////////////////////////
/**
* Set permissions for the folders used by the application.
*
* @return bool
*/
protected function setApplicationPermissions()
{
$files = (array) $this->rocketeer->getOption('remote.permissions.files');
foreach ($files as &$file) {
$this->setPermissions($file);
}
return true;
}
}