Skip to content

Commit 698a945

Browse files
committed
Updated build process
1 parent f09c014 commit 698a945

File tree

5 files changed

+82
-44
lines changed

5 files changed

+82
-44
lines changed

.github/workflows/build_and_deploy.yaml

+7-1
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ jobs:
2020
with:
2121
hugo-version: '0.120.4'
2222

23+
- name: Setup PHP
24+
uses: shivammathur/setup-php@v2
25+
with:
26+
php-version: 8.2
27+
coverage: none
28+
2329
- name: Build all books
24-
run: make build
30+
run: ./book build-all
2531

2632
- name: Deploy
2733
uses: appleboy/scp-action@master

Makefile

-29
This file was deleted.

README.md

+4-12
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,18 @@ The documentation is built using the [Hugo site generator](https://gohugo.io/),
2424
thus you need to [install Hugo](https://gohugo.io/getting-started/installing/)
2525
first on your system.
2626

27-
Building is done using the `make` command. There are different commands available
27+
Building is done using a PHP file. There are different commands available
2828
depending on what part of the documentation you want to build.
2929

3030
```
31-
make build-dev
32-
make build-manual
31+
./book build-<book>
3332
```
3433

3534
Builds the entire documentation into the `build` directory.
3635

3736
```
38-
make live-dev
39-
make live-manual
37+
./book live-<book>
4038
```
4139

4240
Spins up the development server which automatically tracks changes in the `docs`
43-
directory and rebuilds the front end. You can access the front end on [http://localhost:1313](http://localhost:1313).
44-
45-
```
46-
make clean
47-
```
48-
49-
Cleans the build directory.
41+
directory and rebuilds the front end. You can access the front end on [http://localhost:1313](http://localhost:1313).

book

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$books = $folders = array_map(function($dir) {
5+
return basename($dir);
6+
}, glob(__DIR__ . '/docs/*', GLOB_ONLYDIR));
7+
8+
$commands = ['build-all'];
9+
10+
foreach ($books as $book) {
11+
$commands[] = 'build-' . $book;
12+
$commands[] = 'live-' . $book;
13+
}
14+
15+
$command = $_SERVER['argv'][1] ?? '';
16+
17+
if (!in_array($command, $commands, true)) {
18+
echo 'Must run one of the following commands:' . "\n- " . implode("\n- ", $commands);
19+
exit(1);
20+
}
21+
22+
$runCommand = function (string $command) {
23+
echo $command . "\n";
24+
echo system($command);
25+
};
26+
27+
$buildBook = function(string $book) use ($runCommand) {
28+
$command = <<<COMMAND
29+
cd page; hugo \
30+
--cleanDestinationDir \
31+
--environment {book} \
32+
--destination ../build/{book} \
33+
--logLevel info \
34+
--baseURL https://extensions.terminal42.ch/docs/{book}/
35+
COMMAND;
36+
37+
$runCommand(str_replace('{book}', $book, $command));
38+
};
39+
40+
41+
$liveBook = function(string $book) use ($runCommand) {
42+
$command = <<<COMMAND
43+
cd page; hugo server \
44+
--cleanDestinationDir \
45+
--environment {book} \
46+
--destination ../build/{book} \
47+
--logLevel info
48+
COMMAND;
49+
50+
$runCommand(str_replace('{book}', $book, $command));
51+
};
52+
53+
preg_match('/^(build|live)-(.*)/', $command, $matches);
54+
55+
if ('build-all' === $matches[0]) {
56+
foreach ($books as $book) {
57+
$buildBook($book);
58+
}
59+
return;
60+
}
61+
62+
if ('build' === $matches[1]) {
63+
$buildBook($matches[2]);
64+
return;
65+
}
66+
67+
if ('live' === $matches[1]) {
68+
$liveBook($matches[2]);
69+
return;
70+
}

docs/how-it-works/_index.de.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,4 @@ auth.json zu kopieren. Weitere Informationen findest du im [Handbuch von Compose
7171

7272
{{% /tab %}}
7373

74-
{{< /tabs >}}
75-
74+
{{< /tabs >}}

0 commit comments

Comments
 (0)