-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoboFile.php
61 lines (50 loc) · 1.4 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
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFile extends \Robo\Tasks {
function satisDirExists() {
exec('ls -l vendor/bin/satis 2> /dev/null', $output, $satis_exit_code);
return ($satis_exit_code === 0) ? TRUE: FALSE;
}
function getBuildRepo() {
$collection = $this->collectionBuilder();
$collection->taskDeleteDir('build')
->taskGitStack()
->stopOnFail()
->cloneShallow('git@github.com:DeloitteDigitalAPAC/qd-satis.git', 'build', 'gh-pages');
return $collection->run();
}
function buildSatis() {
return $this->taskExec('php vendor/bin/satis build satis.json build')
->run();
}
function publishChanges() {
$user_name = exec('git config user.name');
$current_commit = exec('git rev-parse --verify HEAD');
return $this->taskGitStack()
->stopOnFail()
->dir('build')
->add('-A')
->commit("Robo build - $current_commit - $user_name")
->push('origin', 'gh-pages')
->run();
}
function build($opts = ['publish' => false]) {
$this->stopOnFail(TRUE);
$this->getBuildRepo();
$this->buildSatis();
$this->taskGitStack()
->dir('build')
->exec('status')
->run();
if ($opts['publish']) {
$this->publishChanges();
}
}
function serve() {
$this->_exec('php -S localhost:8000 -t build');
}
}