Add new GIF asset and enhance image optimization process #129
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: 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: Cache Poetry dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cache/pypoetry | |
.venv | |
key: ${{ runner.os }}-poetry-dev-${{ hashFiles('pyproject.toml') }} | |
restore-keys: | | |
${{ runner.os }}-poetry-dev- | |
${{ 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: Optimize images for web | |
run: | | |
poetry 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: | | |
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 |