Skip to content

Build and deploy documentation #541

Build and deploy documentation

Build and deploy documentation #541

Workflow file for this run

name: Build and deploy documentation
on:
push:
branches: main
paths:
- 'docs/**'
- '.github/workflows/build_docs.yml'
pull_request:
paths:
- 'docs/**'
- '.github/workflows/build_docs.yml'
workflow_dispatch:
# Every night at midnight build docs if Animate, Goalie, Movement, or UM2N have been updated in the last 24h
schedule:
- cron: '0 0 * * *'
permissions: {}
concurrency:
group: 'build_docs-${{ github.ref }}'
cancel-in-progress: true
jobs:
# Check if there have been commits on the main branch of other repos in the last 24h
check_updates:
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
updates_found: ${{ steps.check_repos.outputs.updates_found }}
steps:
- name: Set up environment
run: |
APIURL="https://api.github.com/repos/mesh-adaptation"
echo "REPOS=${APIURL}/animate ${APIURL}/goalie ${APIURL}/movement ${APIURL}/UM2N" >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_ENV
- name: Check for updates in repositories
id: check_repos
run: |
for REPO in $REPOS; do
echo "Checking $REPO"
COMMITS=$(curl -L -H "Authorization: token $GITHUB_TOKEN" "$REPO/commits?sha=main&since=$(date -d '24 hours ago' +'%Y-%m-%dT%H:%M:%SZ')")
echo $COMMITS
if [ ${#COMMITS} -gt 10 ]; then
echo "Found new commits in $REPO"
echo "updates_found=true" >> $GITHUB_OUTPUT
fi
done
build_docs:
runs-on: ubuntu-latest
timeout-minutes: 30
needs: check_updates
container:
image: ghcr.io/mesh-adaptation/firedrake-um2n:latest
options: --user root
volumes:
- ${{ github.workspace }}:/root/output
if: ${{ needs.check_updates.outputs.updates_found == 'true' || github.event_name != 'schedule' }}
steps:
- name: Export PYTHONPATH
run: |
PYTHONVERSION=$(python3 -c "import sys; print('.'.join(sys.version.split('.')[:2]))")
echo "PYTHONPATH=/opt/firedrake:/root/animate:/root/goalie:/root/movement:/root/um2n:/root/.local/lib/python${PYTHONVERSION}/site-packages" >> $GITHUB_ENV
- uses: actions/checkout@v5
with:
persist-credentials: false
- name: Update Animate, Goalie, Movement, and UM2N
run: |
git config --global --add safe.directory '*'
for REPO in animate goalie movement UM2N; do
cd /root/${REPO}
git pull
done
working-directory: /root/output/
shell: bash
- name: Install Sphinx and other dependencies
run: python3 -m pip install -r requirements.txt
working-directory: /root/output/
shell: bash
- name: Build HTML Documentation
run: |
set -e
cd docs
make run_animate_demos
make run_goalie_demos
make run_movement_demos
make html
working-directory: /root/output/
shell: bash
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: /root/output/docs/build/html
deploy:
runs-on: ubuntu-latest
timeout-minutes: 5
needs: build_docs
if: ${{ github.ref == 'refs/heads/main' }}
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4