name: Build and Deploy Documentation on: push: branches: [ main, develop ] paths: [ 'docs/**', 'semanticore/**', 'README.md', 'pyproject.toml' ] pull_request: branches: [ main ] paths: [ 'docs/**', 'semanticore/**', 'README.md', 'pyproject.toml' ] workflow_dispatch: 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.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e ".[docs,dev]" pip install sphinx-rtd-theme sphinx-copybutton sphinx-tabs - name: Build documentation run: | cd docs make html make linkcheck - name: Upload documentation artifacts uses: actions/upload-artifact@v3 with: name: documentation path: docs/_build/html/ deploy-docs: needs: build-docs runs-on: ubuntu-latest if: github.ref == 'refs/heads/main' steps: - name: Checkout repository uses: actions/checkout@v4 - name: Download documentation artifacts uses: actions/download-artifact@v3 with: name: documentation path: docs/_build/html/ - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_dir: ./docs/_build/html cname: semanticore.readthedocs.io test-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.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install -e ".[docs,dev]" pip install sphinx-rtd-theme sphinx-copybutton sphinx-tabs - name: Test documentation build run: | cd docs make html make linkcheck make doctest - name: Check for broken links run: | cd docs make linkcheck 2>&1 | tee linkcheck.log if grep -q "broken" linkcheck.log; then echo "Broken links found in documentation" cat linkcheck.log exit 1 fi lint-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.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install doc8 sphinx-lint - name: Lint documentation run: | doc8 docs/ sphinx-lint docs/ spell-check: 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.11' cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install sphinxcontrib-spelling - name: Spell check documentation run: | cd docs make spelling