Gravwell v5.6.3 #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Build HTML" | |
on: | |
release: | |
types: | |
- published | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | |
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
html-build: | |
name: Build HTML | |
runs-on: WikiBuilder | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Nix | |
uses: cachix/install-nix-action@v25 | |
with: | |
nix_path: nixpkgs=channel:nixos-unstable | |
- name: Build and package documentation | |
run: | | |
# Fail on any error | |
set -e | |
# Be chatty | |
set -x | |
# Install prereqs | |
sudo apt install -y moreutils | |
build_docs () { | |
if [[ "${{ vars.VERSION_LIST_URL }}" != "" ]] | |
then | |
nix-build --arg VERSION_LIST_URL '${{ vars.VERSION_LIST_URL }}' | |
else | |
nix-build | |
fi | |
} | |
# Make temporary location for build results | |
export BUILD_DEST="$( mktemp --directory --tmpdir=${{ runner.temp }} )" | |
# Fetch all remote refs | |
git fetch --all | |
# Checkout the tag that triggered this run | |
git checkout ${{ github.ref_name }} | |
# There should only be one marked "preferred": the latest release | |
cat _static/versions.json | jq -r 'map(select(.preferred)) | length | if . != 1 then ("exactly one version should be marked preferred\n" | halt_error(1)) else "ok" end ' | |
# Adjust the urls in versions.json by prepending the base path, if it's present | |
if [[ "${{ vars.BASE_PATH }}" != "" ]] | |
then | |
cat _static/versions.json | jq '.[].url |= "${{ vars.BASE_PATH }}\(.)"' | sponge _static/versions.json | |
cat _static/versions.json | |
fi | |
# Build and copy to build destination | |
build_docs | |
cp -r ./result/html $BUILD_DEST | |
chmod --recursive +w $BUILD_DEST | |
# Reset the versions file to avoid git-related confustion | |
git checkout _static/versions.json | |
# Checkout and build each non-latest version listed in versions.json. Then copy them to build destination. | |
for v in $(cat _static/versions.json | jq -r 'map(select(.preferred != true)) | map(.version) | join(" ")') | |
do | |
git checkout release/$v | |
git pull | |
build_docs | |
cp -r ./result/html $BUILD_DEST/html/$v | |
chmod --recursive +w $BUILD_DEST | |
echo "Disallow: /$v/" >> $BUILD_DEST/html/robots.txt | |
done | |
# Go back to the triggering branch | |
git checkout ${{ github.ref_name }} | |
# Deduplicate images | |
if [[ "${{ vars.BASE_PATH }}" != "" ]] | |
then | |
nix-shell --run "dedup-links --baseurl=${{ vars.BASE_PATH }} $BUILD_DEST/html" | |
else | |
nix-shell --run "dedup-links $BUILD_DEST/html" | |
fi | |
echo "BUILD_DEST=${BUILD_DEST}" >> "$GITHUB_ENV" | |
- name: Upload pages artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: "${{ env.BUILD_DEST }}/html" | |
deploy: | |
name: Deploy Pages | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: html-build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |