Update Poetry version in mkdocs-build workflow to 1.8.5 for improved … #148
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 | |
with: | |
fetch-depth: 0 | |
- name: Check initial disk space | |
run: df -h | |
- name: Set up Python | |
id: setup-python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12' | |
- name: Disk space after python setup, before apt install | |
run: | | |
echo "Disk space after python setup:" | |
df -h | |
- 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: Disk space after apt install | |
run: | | |
echo "Disk space after apt install:" | |
df -h | |
- name: Install Poetry (for requirements generation only) | |
uses: snok/install-poetry@v1 | |
with: | |
version: 1.8.5 | |
virtualenvs-create: false | |
- name: Free up disk space | |
run: | | |
echo "Disk space before cleanup:" | |
df -h | |
# sudo rm -rf /usr/share/dotnet | |
# sudo rm -rf /usr/local/lib/android | |
# sudo rm -rf /opt/ghc | |
echo "Disk space after cleanup:" | |
df -h | |
- name: Generate requirements.txt from Poetry | |
run: | | |
poetry export --format=requirements.txt --group dev --without-hashes > requirements-dev.txt | |
echo "Generated requirements-dev.txt:" | |
head -10 requirements-dev.txt | |
- name: Cache pip dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: pip-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('requirements-dev.txt') }} | |
restore-keys: | | |
pip-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}- | |
- name: Install dependencies with pip | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-dev.txt | |
- name: Check disk space and artifact sizes after install | |
run: | | |
echo "Disk space after installing dependencies:" | |
df -h | |
echo "Size of pip cache:" | |
du -sh ~/.cache/pip | |
- name: Optimize images for web | |
run: | | |
python tools/optimize_images.py --quality 75 --max-width 1600 --max-height 900 --overwrite | |
- name: Build MkDocs site | |
env: | |
JUPYTER_PLATFORM_DIRS: 1 # Suppress Jupyter deprecation warnings | |
run: | | |
mkdocs build --strict --verbose | |
- name: Check disk space after site build | |
run: | | |
echo "Disk space after building site:" | |
df -h | |
echo "Size of generated site:" | |
du -sh site | |
- 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 |