| 1 |
name: Build Docs |
| 2 |
on: |
| 3 |
push: |
| 4 |
branches: |
| 5 |
- master |
| 6 |
pull_request: |
| 7 |
permissions: {} |
| 8 |
|
| 9 |
jobs: |
| 10 |
changes: |
| 11 |
runs-on: ubuntu-latest |
| 12 |
# Required permissions |
| 13 |
permissions: |
| 14 |
pull-requests: read |
| 15 |
timeout-minutes: 5 |
| 16 |
# Set job outputs to values from filter step |
| 17 |
outputs: |
| 18 |
docs: ${{ steps.filter.outputs.docs }} |
| 19 |
steps: |
| 20 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 21 |
with: |
| 22 |
persist-credentials: false |
| 23 |
# For pull requests it's not necessary to checkout the code but for the main branch it is |
| 24 |
- uses: dorny/paths-filter@7b450fff21473bca461d4b92ce414b9d0420d706 # v4.0.2 |
| 25 |
id: filter |
| 26 |
with: |
| 27 |
filters: | |
| 28 |
docs: |
| 29 |
- README.md |
| 30 |
- docs/** |
| 31 |
- docs_src/** |
| 32 |
- pyproject.toml |
| 33 |
- uv.lock |
| 34 |
- .github/workflows/build-docs.yml |
| 35 |
- .github/workflows/deploy-docs.yml |
| 36 |
- scripts/docs.py |
| 37 |
langs: |
| 38 |
needs: |
| 39 |
- changes |
| 40 |
if: ${{ needs.changes.outputs.docs == 'true' }} |
| 41 |
runs-on: ubuntu-latest |
| 42 |
timeout-minutes: 5 |
| 43 |
outputs: |
| 44 |
langs: ${{ steps.show-langs.outputs.langs }} |
| 45 |
steps: |
| 46 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 47 |
with: |
| 48 |
persist-credentials: false |
| 49 |
- name: Set up Python |
| 50 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 51 |
with: |
| 52 |
python-version-file: ".python-version" |
| 53 |
- name: Setup uv |
| 54 |
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0 |
| 55 |
with: |
| 56 |
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum. |
| 57 |
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837 |
| 58 |
version: "0.11.18" |
| 59 |
enable-cache: true |
| 60 |
cache-dependency-glob: | |
| 61 |
pyproject.toml |
| 62 |
uv.lock |
| 63 |
- name: Install docs extras |
| 64 |
run: uv sync --locked --no-dev --group docs |
| 65 |
- name: Export Language Codes |
| 66 |
id: show-langs |
| 67 |
run: | |
| 68 |
echo "langs=$(uv run ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT |
| 69 |
|
| 70 |
build-docs: |
| 71 |
needs: |
| 72 |
- changes |
| 73 |
- langs |
| 74 |
if: ${{ needs.changes.outputs.docs == 'true' }} |
| 75 |
runs-on: ubuntu-latest |
| 76 |
timeout-minutes: 7 |
| 77 |
strategy: |
| 78 |
matrix: |
| 79 |
lang: ${{ fromJson(needs.langs.outputs.langs) }} |
| 80 |
steps: |
| 81 |
- name: Dump GitHub context |
| 82 |
env: |
| 83 |
GITHUB_CONTEXT: ${{ toJson(github) }} |
| 84 |
run: echo "$GITHUB_CONTEXT" |
| 85 |
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 |
| 86 |
with: |
| 87 |
persist-credentials: false |
| 88 |
- name: Set up Python |
| 89 |
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0 |
| 90 |
with: |
| 91 |
python-version-file: ".python-version" |
| 92 |
- name: Setup uv |
| 93 |
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0 |
| 94 |
with: |
| 95 |
# Before upgrading uv version, make sure astral-sh/setup-uv knows its checksum. |
| 96 |
# See: https://github.com/astral-sh/setup-uv/issues/851#issuecomment-4282017837 |
| 97 |
version: "0.11.18" |
| 98 |
enable-cache: true |
| 99 |
cache-dependency-glob: | |
| 100 |
pyproject.toml |
| 101 |
uv.lock |
| 102 |
- name: Install docs extras |
| 103 |
run: uv sync --locked --no-dev --group docs |
| 104 |
- name: Update Languages |
| 105 |
run: uv run ./scripts/docs.py update-languages |
| 106 |
- uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 |
| 107 |
with: |
| 108 |
key: zensical-${{ matrix.lang }}-${{ github.ref }} |
| 109 |
path: site_zensical_src/${{ matrix.lang }}/.cache |
| 110 |
- name: Build Docs |
| 111 |
run: | # zizmor: ignore[template-injection] - comes from trusted source |
| 112 |
uv run ./scripts/docs.py build-lang ${{ matrix.lang }} |
| 113 |
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 |
| 114 |
with: |
| 115 |
name: docs-site-${{ matrix.lang }} |
| 116 |
# English owns root static assets. Translated pages reference /img, /css, |
| 117 |
# and /js, so omit duplicated language-local copies from artifacts. |
| 118 |
path: | |
| 119 |
./site/** |
| 120 |
!./site/${{ matrix.lang }}/img/** |
| 121 |
!./site/${{ matrix.lang }}/css/** |
| 122 |
!./site/${{ matrix.lang }}/js/** |
| 123 |
include-hidden-files: true |
| 124 |
|
| 125 |
# https://github.com/marketplace/actions/alls-green#why |
| 126 |
docs-all-green: # This job does nothing and is only used for the branch protection |
| 127 |
if: always() |
| 128 |
needs: |
| 129 |
- langs |
| 130 |
- build-docs |
| 131 |
runs-on: ubuntu-latest |
| 132 |
steps: |
| 133 |
- name: Decide whether the needed jobs succeeded or failed |
| 134 |
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2 |
| 135 |
with: |
| 136 |
jobs: ${{ toJSON(needs) }} |
| 137 |
allowed-skips: langs, build-docs |