-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathRoboFile.php
More file actions
136 lines (115 loc) · 3.7 KB
/
RoboFile.php
File metadata and controls
136 lines (115 loc) · 3.7 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
private function _sources() {
$sources = [
// DKAN Open Data Stack Source
"git@github.com:OpenDataStack/dkan-opendatastack.git" => "src/dkan-opendatastack"
];
return $sources;
}
public function setup()
{
$this->io()->section("Set up project for development");
$this->_mkdir('src');
foreach ($this->_sources() as $repo => $destination) {
// Clone
$this->taskGitStack()
->stopOnFail()
->cloneRepo($repo, $destination)
->run();
}
}
public function gitPull()
{
$this->io()->section("Update all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
$this->taskGitStack()
->dir($destination)
->stopOnFail()
->pull()
->run();
}
}
public function gitPush()
{
$this->io()->section("Push all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
$this->taskGitStack()
->dir($destination)
->stopOnFail()
->push()
->run();
}
}
public function gitStatus()
{
$this->io()->section("Status of all repositories");
foreach ($this->_sources() + ['repo' => '.'] as $repo => $destination) {
$this->taskExec("git status")
->dir($destination)
->run();
}
}
public function dockerUpProd()
{
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec('docker-compose')->arg('up')->run();
}
public function dockerUpDev()
{
$dockerCompose = [
'docker-compose',
'-f docker-compose.yml',
];
// 'Darwin' or 'Linux'
if (PHP_OS == 'Darwin') {
$this->taskExec('docker-sync')->arg('stop')->run();
$this->taskExec('docker-sync')->arg('clean')->run();
$this->taskExec('docker-sync')->arg('start')->run();
$dockerCompose[] = '-f docker-compose.dev.mac.yml';
}
// Linux
else {
$dockerCompose[] = '-f docker-compose.dev.linux.yml';
}
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec(implode(' ', $dockerCompose))->args('up')->run();
}
public function dockerBuild()
{
$this->taskExec('docker-compose')->arg('stop')->run();
$this->taskExec('docker-compose')
->arg('up')
->option('build')
->run();
}
public function dockerPush()
{
$localTag = 'dkan-opendatastack';
$remoteTag = 'opendatastack/' . $localTag;
$this->taskExec('docker build -t ' . $localTag . ' ' . '.')
->run();
$this->taskExec('docker tag ' . $localTag . ' ' . $remoteTag)
->run();
$this->taskExec('docker push ' . $remoteTag)
->run();
}
public function dkanInstall()
{
$this->taskExec('
time docker-compose exec --user=www-data dkan_apache_php /bin/bash -c "cd /var/www/html/docroot && drush si dkan --verbose --account-pass=\'admin\' --site-name=\'DKAN\' install_configure_form.update_status_module=\'array(FALSE,FALSE)\' --yes"
')->run();
}
public function dkanDrush(array $args)
{
$this->taskExec('
docker-compose exec --user=www-data dkan_apache_php /bin/bash -c "cd /var/www/html/docroot && drush ' . implode(' ', $args) . '"
')->run();
}
}