Update MkDocs configuration and dependencies for improved social card… #112
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: Build and Deploy MkDocs | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
build-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Cache and install system dependencies for social cards | |
uses: awalsh128/cache-apt-pkgs-action@latest | |
with: | |
packages: libcairo2-dev libfreetype6-dev libffi-dev libjpeg-dev libpng-dev libz-dev | |
version: 1.0 | |
- name: Install Poetry | |
uses: snok/install-poetry@v1 | |
with: | |
version: latest | |
virtualenvs-create: true | |
virtualenvs-in-project: true | |
- name: Extract MkDocs Material version for cache key | |
id: mkdocs-version | |
run: | | |
MKDOCS_VERSION=$(grep 'mkdocs-material' pyproject.toml | sed 's/.*"\^//' | sed 's/".*//') | |
echo "version=$MKDOCS_VERSION" >> $GITHUB_OUTPUT | |
echo "MkDocs Material version: $MKDOCS_VERSION" | |
- name: Cache Poetry dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pypoetry | |
.venv | |
key: ${{ runner.os }}-poetry-mkdocs-${{ steps.mkdocs-version.outputs.version }} | |
restore-keys: | | |
${{ runner.os }}-poetry-mkdocs- | |
${{ runner.os }}-poetry- | |
- name: Install dependencies | |
run: | | |
poetry config installer.parallel true | |
poetry config cache-dir ~/.cache/pypoetry | |
poetry install --only dev --no-root | |
- name: Build MkDocs site | |
env: | |
JUPYTER_PLATFORM_DIRS: 1 # Suppress Jupyter deprecation warnings | |
run: | | |
poetry run mkdocs build --strict --verbose | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./site | |
cname: pytorchcourse.com |