Skip to content

compile-docs

compile-docs #1076

Workflow file for this run

name: Compile documentation
on:
push:
branches:
- main
repository_dispatch:
types: [compile-docs]
permissions:
contents: write
jobs:
deploy:
env:
RELEASE_TAG: ${{ github.event.client_payload.tag }}
runs-on: ubuntu-latest
# One job at a time, cancel any pending jobs (but not those in progress).
concurrency:
group: compile-docs-${{ github.ref }}
steps:
- uses: actions/checkout@v4
with:
ref: main
path: main
- name: "Checkout the repository (stable)"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: actions/checkout@v4
with:
ref: stable
path: stable
- name: "Copy stable datasets, categories, tasks, profiles, main page, schemas"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
run: |
# Preserve the manually edited files from the main branch
cp main/docs/schema/index.md stable/docs/schema/index.md
cp main/docs/datasets/index.md stable/docs/datasets/index.md
cp main/docs/categories/index.md stable/docs/categories/index.md
# Remove the auto-generated dev content
rm -r main/docs/datasets/* main/docs/categories/* main/docs/tasks/* \
main/docs/profiles/* main/docs/schema/* main/docs/index.md || true
# Copy the stable content
cp -r stable/docs/datasets stable/docs/categories stable/docs/tasks \
stable/docs/profiles stable/docs/schema stable/docs/index.md \
main/docs || true
cp stable/docs/datasets/table.md main/docs/datasets/table.md || true
cp stable/docs/results/table.md main/docs/results/table.md || true
# *** the part about adding redirects ***
- name: "Checkout the repository (gh-pages)"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: actions/checkout@v4
with:
ref: gh-pages
path: gh-pages
- name: "Add PURL redirects to the new stable release"
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: docker://ghcr.io/riverbench/ci-worker:main
with:
args: bash -c "for SCHEMA in $(ls -1 main/docs/schema/*.md | grep -v index.md | grep -Po '[^/]*$') ; do ci-worker generate-redirect ./gh-pages schema \"${SCHEMA%.md}\" \"${RELEASE_TAG#v}\" ; done ; for DATASET in $(ls -1 main/docs/datasets | grep -v '[.]' | grep -Po '[^/]*$') ; do ci-worker generate-redirect ./gh-pages datasets \"${DATASET}\" \"${RELEASE_TAG#v}\" ; done"
- name: Commit changes to the gh-pages branch
if: ${{ github.event.client_payload.tag && github.event.client_payload.tag != 'dev' }}
uses: EndBug/add-and-commit@v9
with:
cwd: ./gh-pages
message: ${{ format('Update redirects stable release ({0})', github.event.client_payload.tag) }}
default_author: github_actions
add: '.'
pull: '--rebase --autostash'
push: true
# *** end of the part about adding redirects ***
- name: Generate nav
uses: docker://ghcr.io/riverbench/ci-worker:main
with:
args: ci-worker nav-gen ./main ./main/mkdocs_2.yml
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- name: Install dependencies
run: pip install -r main/requirements.txt
- name: Deploy site
run: |
cd main
mv mkdocs_2.yml mkdocs.yml
git fetch origin gh-pages --depth=1
git config user.name ci-bot
git config user.email ci-bot@example.com
if [[ $RELEASE_TAG == v* ]] ; then
mike deploy --push --update-aliases "${RELEASE_TAG#v}" stable
else
mike deploy --push --update-aliases dev latest
fi