2021-08-24 14:21:34 +00:00
|
|
|
name: Build Docs
|
|
|
|
on:
|
|
|
|
push:
|
2022-02-13 17:14:02 +00:00
|
|
|
branches:
|
|
|
|
- main
|
2021-08-24 14:21:34 +00:00
|
|
|
pull_request:
|
2023-07-29 10:32:47 +00:00
|
|
|
types:
|
|
|
|
- opened
|
|
|
|
- synchronize
|
2021-08-24 14:21:34 +00:00
|
|
|
jobs:
|
2023-07-31 15:15:43 +00:00
|
|
|
changes:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
# Required permissions
|
|
|
|
permissions:
|
|
|
|
pull-requests: read
|
|
|
|
# Set job outputs to values from filter step
|
|
|
|
outputs:
|
|
|
|
docs: ${{ steps.filter.outputs.docs }}
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
# For pull requests it's not necessary to checkout the code but for the main branch it is
|
|
|
|
- uses: dorny/paths-filter@v2
|
|
|
|
id: filter
|
|
|
|
with:
|
|
|
|
filters: |
|
|
|
|
docs:
|
|
|
|
- README.md
|
|
|
|
- docs/**
|
|
|
|
- docs_src/**
|
|
|
|
- pyproject.toml
|
|
|
|
- mkdocs.yml
|
|
|
|
- mkdocs.insiders.yml
|
|
|
|
|
2021-08-24 14:21:34 +00:00
|
|
|
build-docs:
|
2023-07-31 15:15:43 +00:00
|
|
|
needs:
|
|
|
|
- changes
|
|
|
|
if: ${{ needs.changes.outputs.docs == 'true' }}
|
2023-07-29 10:32:47 +00:00
|
|
|
runs-on: ubuntu-latest
|
2021-08-24 14:21:34 +00:00
|
|
|
steps:
|
|
|
|
- name: Dump GitHub context
|
|
|
|
env:
|
|
|
|
GITHUB_CONTEXT: ${{ toJson(github) }}
|
|
|
|
run: echo "$GITHUB_CONTEXT"
|
2023-07-29 10:32:47 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-08-24 14:21:34 +00:00
|
|
|
- name: Set up Python
|
2022-11-04 21:43:45 +00:00
|
|
|
uses: actions/setup-python@v4
|
2021-08-24 14:21:34 +00:00
|
|
|
with:
|
2023-07-29 10:32:47 +00:00
|
|
|
python-version: "3.11"
|
2022-11-12 06:37:34 +00:00
|
|
|
- uses: actions/cache@v3
|
2021-08-24 14:21:34 +00:00
|
|
|
id: cache
|
|
|
|
with:
|
|
|
|
path: ${{ env.pythonLocation }}
|
2023-07-31 15:15:43 +00:00
|
|
|
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
|
|
|
|
- name: Install Poetry
|
2021-08-24 14:21:34 +00:00
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: |
|
|
|
|
python -m pip install --upgrade pip
|
2023-07-29 10:32:47 +00:00
|
|
|
python -m pip install "poetry"
|
|
|
|
python -m poetry self add poetry-version-plugin
|
2021-08-24 14:21:34 +00:00
|
|
|
- name: Configure poetry
|
2021-08-24 18:14:33 +00:00
|
|
|
run: python -m poetry config virtualenvs.create false
|
2021-08-24 14:21:34 +00:00
|
|
|
- name: Install Dependencies
|
|
|
|
if: steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: python -m poetry install
|
|
|
|
- name: Install Material for MkDocs Insiders
|
2023-07-29 10:32:47 +00:00
|
|
|
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true'
|
|
|
|
run: python -m poetry run pip install git+https://${{ secrets.SQLMODEL_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git
|
2022-11-12 06:37:34 +00:00
|
|
|
- uses: actions/cache@v3
|
2021-11-30 16:27:50 +00:00
|
|
|
with:
|
|
|
|
key: mkdocs-cards-${{ github.ref }}
|
|
|
|
path: .cache
|
2021-08-24 14:21:34 +00:00
|
|
|
- name: Build Docs
|
2023-07-29 10:32:47 +00:00
|
|
|
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true
|
2021-08-24 18:14:33 +00:00
|
|
|
run: python -m poetry run mkdocs build
|
2021-12-13 10:47:07 +00:00
|
|
|
- name: Build Docs with Insiders
|
2023-07-29 10:32:47 +00:00
|
|
|
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
|
2021-12-13 10:47:07 +00:00
|
|
|
run: python -m poetry run mkdocs build --config-file mkdocs.insiders.yml
|
2022-11-04 21:00:21 +00:00
|
|
|
- uses: actions/upload-artifact@v3
|
2021-08-24 14:21:34 +00:00
|
|
|
with:
|
2023-07-31 15:15:43 +00:00
|
|
|
name: docs-site
|
|
|
|
path: ./site/**
|
|
|
|
|
|
|
|
# https://github.com/marketplace/actions/alls-green#why
|
|
|
|
docs-all-green: # This job does nothing and is only used for the branch protection
|
|
|
|
if: always()
|
|
|
|
needs:
|
|
|
|
- build-docs
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Decide whether the needed jobs succeeded or failed
|
|
|
|
uses: re-actors/alls-green@release/v1
|
2021-08-24 14:21:34 +00:00
|
|
|
with:
|
2023-07-31 15:15:43 +00:00
|
|
|
jobs: ${{ toJSON(needs) }}
|
|
|
|
allowed-skips: build-docs
|