Skip to content

Commit b05080f

Browse files
committed
Add script to build the GitHub Pages locally
This script is also run in the CI job
1 parent da2507a commit b05080f

3 files changed

Lines changed: 77 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ jobs:
1717
name: pdfs
1818
path: output_pdfs
1919

20+
build-github-pages:
21+
runs-on: ubuntu-latest
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: generate the GitHub Pages locally in order to check for errors
25+
run: ./tools/build-github-pages.sh build
26+
2027
markdown-link-check:
2128
runs-on: ubuntu-latest
2229
steps:

tools/build-github-pages.sh

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
3+
# SPDX-FileCopyrightText: Copyright 2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
4+
# SPDX-License-Identifier: Apache-2.0
5+
6+
########################### BUILD GITHUB PAGES ################################
7+
#
8+
# This script uses Git and Docker to build the GitHub Pages version of the ACLE
9+
# project locally.
10+
#
11+
# It accepts one of two options: build or serve.
12+
#
13+
# build generates the web pages, but does not launch a web server.
14+
# serve generates them and also launches a web server.
15+
#
16+
# Once web server is launched, one can access the server using any web browser.
17+
# Its address is printed in the output.
18+
#
19+
###############################################################################
20+
21+
22+
if [ $# -ne 1 ]; then
23+
echo "Please provide one option: 'build' or 'serve'."
24+
exit 1
25+
fi
26+
27+
if [ "$1" != "build" ] && [ "$1" != "serve" ]; then
28+
echo "Unsupported option. It must be either 'build' or 'serve'."
29+
exit 1
30+
fi
31+
32+
set -x
33+
34+
ROOTDIR=$(realpath "$(dirname "$(realpath "$0")")/..")
35+
TEMPDIR=$(mktemp -d)
36+
cd $TEMPDIR
37+
git clone https://github.com/github/pages-gem.git
38+
cd pages-gem
39+
make image
40+
cd $ROOTDIR
41+
echo -e "plugins:\n \
42+
- jekyll-coffeescript\n \
43+
- jekyll-default-layout\n \
44+
- jekyll-gist\n \
45+
- jekyll-github-metadata\n \
46+
- jekyll-optional-front-matter\n \
47+
- jekyll-paginate\n \
48+
- jekyll-readme-index\n \
49+
- jekyll-titles-from-headings\n \
50+
- jekyll-relative-links\n" >> _config.yml
51+
cd $TEMPDIR/pages-gem
52+
53+
if [ "$1" == "build" ]; then
54+
SITE=$ROOTDIR
55+
docker run --rm -p 4000:4000 -v `realpath ${SITE}`:/src/site gh-pages jekyll build
56+
elif [ "$1" == "serve" ]; then
57+
SITE=$ROOTDIR make server
58+
fi
59+
60+
return_code=$?
61+
cd $ROOTDIR
62+
git restore _config.yml
63+
64+
exit $return_code

tools/howto-build-github-pages-locally.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ difficult.
1212

1313
This document describes one process to build the GitHub page locally.
1414

15+
## Script
16+
17+
The script `build-github-pages.sh` contained in this same directory automates
18+
this process.
19+
1520
## Prerequisites
1621

1722
- Docker.
@@ -52,4 +57,4 @@ Note: it has only been tested on Linux.
5257
5. On the terminal output, the IP and port of the web server will be shown.
5358
Just open it in a browser.
5459

55-
Incremental builds can be done by starting at step 4.
60+
Incremental builds can be done by starting at step 4.

0 commit comments

Comments
 (0)