This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoboFile.php
70 lines (67 loc) · 2.29 KB
/
RoboFile.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
<?php
use Symfony\Component\Finder\Finder as Finder;
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks
{
/**
* Build containers from base repo.
*/
public function containersBuild()
{
$this->yell("Drupal Dropdock build containers.");
$standard_readme = file_get_contents('README.default.md');
$finder = new Finder();
$finder->directories()->in(__DIR__ . "/containers");
$finder->depth('== 0');
foreach ($finder as $dir) {
$container_source_path = $dir->getRealPath();
$container_name = $dir->getRelativePathname();
$container_dest = realpath("github-repos/docker-drupal-{$container_name}");
if (file_exists($container_dest)) {
$container_readme = "{$container_dest}/README.md";
$this->printTaskInfo('Syncing container:' . $container_name);
$this->taskExec("rm -rf *")
->dir($container_dest)
->run();
$this->taskCopyDir([$container_source_path => $container_dest])->run();
// Update README files.
if (file_exists($container_readme)) {
$readme = file_get_contents($container_readme);
$readme_replace = str_replace('***REPLACE***', $readme, $standard_readme);
$this->taskWriteToFile($container_readme)
->text($readme_replace)
->run();
}
}
}
}
/**
* Commit to gihub.
*/
public function containersPublish()
{
$this->yell("Drupal Docker commit to gihub.");
$finder = new Finder();
$finder->directories()->in(__DIR__ . "/containers");
$finder->depth('== 0');
$update_time = time();
foreach ($finder as $dir) {
$container_source_path = $dir->getRealPath();
$container_name = $dir->getRelativePathname();
$container_dest = realpath("github-repos/docker-drupal-{$container_name}");
if (file_exists($container_dest)) {
$this->taskGitStack()
->stopOnFail()
->dir($container_dest)
->add('-A')
->commit('automatic update container from build: ' . $update_time)
->push('origin','master')
->run();
}
}
}
}