chore: site deployment #1
This file contains hidden or 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: Deploy artifacts | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'docs/**' | |
| - 'exercises/**' | |
| - 'slides/**' | |
| - '.github/workflows/deploy-artifacts.yml' | |
| - 'pyproject.toml' | |
| - 'poetry.lock' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| env: | |
| BASE_URL: "" | |
| EXERCISES_DIR: "exercises/" | |
| EXTRAS_BUILD_DIR: "docs/_build/html/extras" | |
| SITE_BUILD_DIR: "docs/_build/html" | |
| EXTRAS_URL: "https://database-development.erhardt.consulting/extras" | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: 'pages' | |
| cancel-in-progress: false | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 | |
| - name: Install NodeJS 22.x | |
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | |
| with: | |
| node-version: 22.x | |
| - name: Cache NodeJS environment | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: | | |
| **/node_modules | |
| ~/.npm | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node | |
| - name: Install NodeJS dependencies | |
| run: npm ci | |
| - name: Set up python | |
| id: setup-python | |
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5 | |
| with: | |
| python-version: '3.14' | |
| - name: Install Poetry | |
| uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1 | |
| with: | |
| virtualenvs-create: true | |
| virtualenvs-in-project: true | |
| virtualenvs-path: .venv | |
| installer-parallel: true | |
| - name: Load cached venv | |
| id: cached-poetry-dependencies | |
| uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4 | |
| with: | |
| path: .venv | |
| key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | |
| - name: Install Python dependencies | |
| if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | |
| run: poetry install --no-interaction | |
| - name: Build page | |
| run: | | |
| source .venv/bin/activate | |
| cd docs/ | |
| jupyter book build --html --ci | |
| - name: Convert exercises | |
| run: | | |
| find "${EXERCISES_DIR}" -type f -name "*.md" | while read file; do | |
| dir=$(dirname "$file") | |
| base_dir=$(basename "$dir") | |
| filename=$(basename "$file" .md) | |
| target_dir="${EXTRAS_BUILD_DIR}/exercises/${base_dir}" | |
| mkdir -p "${target_dir}" | |
| echo "Processing $file -> ${target_dir}/${filename}.pdf" | |
| podman run --rm -v "$(pwd):/data" docker.io/pandoc/extra \ | |
| --template eisvogel \ | |
| -f markdown \ | |
| -t pdf \ | |
| "/data/${file}" \ | |
| -o "/data/${target_dir}/${filename}.pdf" | |
| done | |
| - name: Convert slides | |
| run: | | |
| npm run slides:pdf | |
| mkdir -p "${EXTRAS_BUILD_DIR}/slides" | |
| cp -r slides/_build/*.pdf "${EXTRAS_BUILD_DIR}/slides" | |
| - name: Build extras index page | |
| run: | | |
| source .venv/bin/activate | |
| cd "${SITE_BUILD_DIR}" | |
| linuxdir2html --links --protocol "${EXTRAS_URL}" ./extras ./extras/index | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 | |
| with: | |
| path: './docs/_build/html' | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 |