Skip to content

Commit 9ad2542

Browse files
ci: parallelize the mdbook build <language> process
1 parent ab26027 commit 9ad2542

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.github/workflows/build.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ set -Eeuo pipefail
1515
book_lang=${1:?"Usage: $0 <book-lang> <dest-dir>"}
1616
dest_dir=${2:?"Usage: $0 <book-lang> <dest-dir>"}
1717

18+
# ensure source dir exists
19+
mkdir -p source
20+
# clean previous build artifacts
21+
SOURCE_DIR="source/${book_lang}"
22+
rm -rf "$SOURCE_DIR"
23+
mkdir "$SOURCE_DIR"
24+
25+
# clone the current state into the source directory
26+
git clone . "$SOURCE_DIR"
27+
28+
# now work from that new directory as the base directory
29+
cd "$SOURCE_DIR"
30+
1831
if [ "$book_lang" = "en" ]; then
1932
echo "::group::Building English course"
2033
else

.github/workflows/publish.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,10 @@ jobs:
5353
run: .github/workflows/build.sh en book
5454

5555
- name: Build all translations
56+
# note: build.sh here uses the given book path relative to source/{language}
5657
run: |
57-
for po_lang in ${{ env.LANGUAGES }}; do
58-
.github/workflows/build.sh $po_lang book/$po_lang
59-
mv book/$po_lang/html book/html/$po_lang
60-
done
61-
58+
parallel -i .github/workflows/build.sh {} book/{} -- ${{ env.LANGUAGES }}
59+
parallel -i mv source/{}/book/{}/html book/html/{} -- ${{ env.LANGUAGES }}
6260
- name: Build translation report
6361
run: i18n-report report book/html/translation-report.html po/*.po
6462

0 commit comments

Comments
 (0)