|
| 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 |
0 commit comments