name: Build Docs on: push: branches: - master pull_request: permissions: {} env: UV_NO_SYNC: true jobs: changes: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read timeout-minutes: 5 # Set job outputs to values from filter step outputs: docs: ${{ steps.filter.outputs.docs }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false # For pull requests it's not necessary to checkout the code but for the main branch it is - uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 id: filter with: filters: | docs: - README.md - docs/** - docs_src/** - pyproject.toml - uv.lock - .github/workflows/build-docs.yml - .github/workflows/deploy-docs.yml - scripts/docs.py langs: needs: - changes if: ${{ needs.changes.outputs.docs == 'true' }} runs-on: ubuntu-latest timeout-minutes: 5 outputs: langs: ${{ steps.show-langs.outputs.langs }} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version-file: ".python-version" - name: Setup uv uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: version: "latest-known" enable-cache: true cache-suffix: docs cache-dependency-glob: | pyproject.toml uv.lock - name: Install docs extras run: uv sync --locked --no-dev --group docs - name: Export Language Codes id: show-langs run: | echo "langs=$(uv run ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT build-docs: needs: - changes - langs if: ${{ needs.changes.outputs.docs == 'true' }} runs-on: ubuntu-latest timeout-minutes: 7 strategy: matrix: lang: ${{ fromJson(needs.langs.outputs.langs) }} steps: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: persist-credentials: false - name: Set up Python uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0 with: python-version-file: ".python-version" - name: Setup uv uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1 with: version: "latest-known" enable-cache: true cache-suffix: docs cache-dependency-glob: | pyproject.toml uv.lock - name: Install docs extras run: uv sync --locked --no-dev --group docs - name: Update Languages run: uv run ./scripts/docs.py update-languages - name: Build Docs run: | # zizmor: ignore[template-injection] - comes from trusted source uv run ./scripts/docs.py build-lang ${{ matrix.lang }} - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 with: name: docs-site-${{ matrix.lang }} # English owns root static assets. Translated pages reference /img, /css, # and /js, so omit duplicated language-local copies from artifacts. path: | ./site/** !./site/${{ matrix.lang }}/img/** !./site/${{ matrix.lang }}/css/** !./site/${{ matrix.lang }}/js/** include-hidden-files: true # 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: - langs - build-docs runs-on: ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 with: jobs: ${{ toJSON(needs) }} allowed-skips: langs, build-docs