Build and Deploy Docs #11
This file contains 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 Docs | |
on: | |
push: | |
branches: | |
pull_request: | |
types: | |
- opened | |
- reopened | |
- synchronize | |
- closed | |
workflow_dispatch: # Allow manual triggering | |
jobs: | |
deploy: | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.x | |
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV | |
- uses: actions/cache@v4 | |
with: | |
key: mkdocs-material-${{ env.cache_id }} | |
path: .cache | |
restore-keys: | | |
mkdocs-material- | |
- name: Install and Build | |
if: github.event.action != 'closed' | |
run: | | |
cd docs | |
pip install -r requirements.txt | |
# Deploy with pr-preview only on PRs | |
- name: Deploy preview | |
if: github.event_name == 'pull_request' | |
uses: rossjrw/pr-preview-action@v1 | |
with: | |
source-dir: ./docs/site | |
# Deploy to GitHub Pages only when the main branch | |
- name: Deploy to GitHub Pages | |
run : | | |
cd docs | |
mkdocs gh-deploy --force | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' |