|
| 1 | +name: Docs |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + paths: |
| 7 | + - 'docs/**' |
| 8 | + - 'mkdocs.yml' |
| 9 | + - 'flixopt/**' |
| 10 | + pull_request: |
| 11 | + paths: |
| 12 | + - 'docs/**' |
| 13 | + - 'mkdocs.yml' |
| 14 | + workflow_dispatch: |
| 15 | + workflow_call: |
| 16 | + inputs: |
| 17 | + deploy: |
| 18 | + type: boolean |
| 19 | + default: false |
| 20 | + version: |
| 21 | + type: string |
| 22 | + required: false |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +env: |
| 29 | + PYTHON_VERSION: "3.11" |
| 30 | + MPLBACKEND: Agg |
| 31 | + PLOTLY_RENDERER: json |
| 32 | + |
| 33 | +jobs: |
| 34 | + build: |
| 35 | + name: Build documentation |
| 36 | + runs-on: ubuntu-24.04 |
| 37 | + timeout-minutes: 30 |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v5 |
| 40 | + with: |
| 41 | + fetch-depth: 0 |
| 42 | + |
| 43 | + - uses: astral-sh/setup-uv@v7 |
| 44 | + with: |
| 45 | + version: "0.9.10" |
| 46 | + enable-cache: true |
| 47 | + |
| 48 | + - uses: actions/setup-python@v6 |
| 49 | + with: |
| 50 | + python-version: ${{ env.PYTHON_VERSION }} |
| 51 | + |
| 52 | + - name: Extract changelog |
| 53 | + run: | |
| 54 | + cp CHANGELOG.md docs/changelog.md |
| 55 | + python scripts/format_changelog.py |
| 56 | +
|
| 57 | + - name: Install dependencies |
| 58 | + run: uv pip install --system ".[docs,full]" |
| 59 | + |
| 60 | + - name: Build docs |
| 61 | + run: mkdocs build --strict |
| 62 | + |
| 63 | + - uses: actions/upload-artifact@v4 |
| 64 | + with: |
| 65 | + name: docs |
| 66 | + path: site/ |
| 67 | + retention-days: 7 |
| 68 | + |
| 69 | + deploy: |
| 70 | + name: Deploy documentation |
| 71 | + needs: build |
| 72 | + if: ${{ inputs.deploy == true && inputs.version != '' }} |
| 73 | + runs-on: ubuntu-24.04 |
| 74 | + permissions: |
| 75 | + contents: write |
| 76 | + steps: |
| 77 | + - uses: actions/checkout@v5 |
| 78 | + with: |
| 79 | + fetch-depth: 0 |
| 80 | + |
| 81 | + - uses: astral-sh/setup-uv@v7 |
| 82 | + with: |
| 83 | + version: "0.9.10" |
| 84 | + enable-cache: true |
| 85 | + |
| 86 | + - uses: actions/setup-python@v6 |
| 87 | + with: |
| 88 | + python-version: ${{ env.PYTHON_VERSION }} |
| 89 | + |
| 90 | + - name: Install mike |
| 91 | + run: uv pip install --system mike |
| 92 | + |
| 93 | + - uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + name: docs |
| 96 | + path: site/ |
| 97 | + |
| 98 | + - name: Configure Git |
| 99 | + run: | |
| 100 | + git config user.name "github-actions[bot]" |
| 101 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 102 | +
|
| 103 | + - name: Deploy docs |
| 104 | + run: | |
| 105 | + VERSION=${{ inputs.version }} |
| 106 | + VERSION=${VERSION#v} |
| 107 | + mike deploy --push --update-aliases --no-build $VERSION latest |
| 108 | + mike set-default --push latest |
0 commit comments