From c7585d78ac0a8eaef2dfd60f5e025ab2869e4efb Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Mon, 10 Aug 2026 10:10:55 -0700 Subject: [PATCH] add github pages workflow for documentation website --- .github/workflows/pages.yml | 44 +++++++++++++++++++++ doc/build-website.sh | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 .github/workflows/pages.yml create mode 100755 doc/build-website.sh diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 0000000..902a7b1 --- /dev/null +++ b/.github/workflows/pages.yml @@ -0,0 +1,44 @@ +name: Publish documentation + +on: + push: + branches: [ master ] + workflow_dispatch: + +permissions: + contents: read + pages: write + id-token: write + +concurrency: + group: pages + cancel-in-progress: true + +jobs: + build: + name: Build website + runs-on: ubuntu-latest + steps: + - name: Prepare + run: | + sudo apt-get update + sudo apt-get install -y pandoc + - name: Check out + uses: actions/checkout@v4 + - name: Build website + run: ./doc/build-website.sh _site + - name: Upload website + uses: actions/upload-pages-artifact@v3 + with: + path: _site + deploy: + name: Deploy to GitHub Pages + needs: build + runs-on: ubuntu-latest + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + steps: + - name: Deploy + id: deployment + uses: actions/deploy-pages@v4 diff --git a/doc/build-website.sh b/doc/build-website.sh new file mode 100755 index 0000000..345b7f1 --- /dev/null +++ b/doc/build-website.sh @@ -0,0 +1,79 @@ +#! /bin/sh +# +# Assembles the documentation website published via GitHub Pages. +# Requires pandoc, which is used to convert README.md to HTML. +# +# Usage: doc/build-website.sh [output-directory] +# + +set -e + +srcdir=`dirname "$0"` +outdir=${1:-_site} + +if ! command -v pandoc > /dev/null 2>&1; then + echo "error: pandoc is required to build the website" >&2 + exit 1 +fi + +mkdir -p "$outdir" +cp "$srcdir/default.css" "$outdir" + +# The HTML files in doc/ are body fragments with no or ; +# they were originally embedded in a site template. This wraps a +# fragment (read from stdin) into a complete page. +emit_page() { + title=$1 + out=$2 + + { + cat << EOF + + + + + +$title + + + + + +EOF + cat + cat << EOF + + +EOF + } > "$out" +} + +pandoc --from gfm --to html "$srcdir/../README.md" \ + | emit_page "TRE" "$outdir/index.html" + +emit_page "TRE API reference manual" "$outdir/tre-api.html" \ + < "$srcdir/tre-api.html" + +emit_page "TRE Regexp Syntax" "$outdir/tre-syntax.html" \ + < "$srcdir/tre-syntax.html"