|
| 1 | +name: 'docs' |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'main' |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - 'ready_for_review' |
| 10 | + - 'opened' |
| 11 | + - 'synchronize' |
| 12 | + workflow_dispatch: |
| 13 | + inputs: |
| 14 | + deploy_target: |
| 15 | + description: 'Deploy target (custom = invoke.ai, ghpages = invoke-ai.github.io/InvokeAI)' |
| 16 | + type: choice |
| 17 | + options: |
| 18 | + - custom |
| 19 | + - ghpages |
| 20 | + default: custom |
| 21 | + |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + pull-requests: read |
| 25 | + |
| 26 | +concurrency: |
| 27 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 28 | + cancel-in-progress: true |
| 29 | + |
| 30 | +jobs: |
| 31 | + changes: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + outputs: |
| 34 | + docs: ${{ steps.manual.outputs.docs || steps.filter.outputs.docs }} |
| 35 | + steps: |
| 36 | + - name: checkout |
| 37 | + uses: actions/checkout@v4 |
| 38 | + with: |
| 39 | + fetch-depth: 0 |
| 40 | + |
| 41 | + - name: mark manual run |
| 42 | + if: github.event_name == 'workflow_dispatch' |
| 43 | + id: manual |
| 44 | + run: echo "docs=true" >> "$GITHUB_OUTPUT" |
| 45 | + |
| 46 | + - name: detect docs-related changes |
| 47 | + if: github.event_name != 'workflow_dispatch' |
| 48 | + id: filter |
| 49 | + uses: dorny/paths-filter@v3 |
| 50 | + with: |
| 51 | + filters: | |
| 52 | + docs: |
| 53 | + - '.github/workflows/deploy-docs.yml' |
| 54 | + - 'docs/**' |
| 55 | + - 'scripts/generate_docs_json.py' |
| 56 | + - 'invokeai/app/**' |
| 57 | + - 'invokeai/backend/**' |
| 58 | + - 'pyproject.toml' |
| 59 | + - 'uv.lock' |
| 60 | +
|
| 61 | + check-and-build: |
| 62 | + needs: changes |
| 63 | + if: | |
| 64 | + github.event_name == 'workflow_dispatch' || |
| 65 | + (github.event_name == 'pull_request' && |
| 66 | + github.event.pull_request.draft == false && |
| 67 | + needs.changes.outputs.docs == 'true') || |
| 68 | + (github.event_name == 'push' && needs.changes.outputs.docs == 'true') |
| 69 | + runs-on: ubuntu-22.04 |
| 70 | + timeout-minutes: 20 |
| 71 | + steps: |
| 72 | + - name: checkout |
| 73 | + uses: actions/checkout@v4 |
| 74 | + |
| 75 | + # Python (needed for generate-docs-data) |
| 76 | + - name: setup uv |
| 77 | + uses: astral-sh/setup-uv@v5 |
| 78 | + with: |
| 79 | + version: '0.6.10' |
| 80 | + enable-cache: true |
| 81 | + python-version: '3.11' |
| 82 | + |
| 83 | + - name: setup python |
| 84 | + uses: actions/setup-python@v5 |
| 85 | + with: |
| 86 | + python-version: '3.11' |
| 87 | + |
| 88 | + # generate_docs_json.py only needs the invokeai package importable |
| 89 | + # (pydantic + invokeai.app/backend). Skip the [test] extra to keep CI fast. |
| 90 | + - name: install python dependencies |
| 91 | + run: uv pip install --editable . |
| 92 | + |
| 93 | + # Node (needed for docs build) |
| 94 | + - name: setup node |
| 95 | + uses: actions/setup-node@v4 |
| 96 | + with: |
| 97 | + node-version: '22.12.0' |
| 98 | + |
| 99 | + - name: setup pnpm |
| 100 | + uses: pnpm/action-setup@v4 |
| 101 | + with: |
| 102 | + version: 10 |
| 103 | + run_install: false |
| 104 | + |
| 105 | + - name: install docs dependencies |
| 106 | + run: pnpm install --prefer-frozen-lockfile |
| 107 | + working-directory: docs |
| 108 | + |
| 109 | + # Checks |
| 110 | + - name: verify generated docs data |
| 111 | + run: pnpm run check-docs-data |
| 112 | + working-directory: docs |
| 113 | + |
| 114 | + - name: build docs |
| 115 | + run: pnpm build |
| 116 | + working-directory: docs |
| 117 | + env: |
| 118 | + DEPLOY_TARGET: ${{ github.event_name == 'workflow_dispatch' && inputs.deploy_target || github.ref == 'refs/heads/main' && 'ghpages' || 'custom' }} |
| 119 | + |
| 120 | + # Upload artifact for deploy (main branch only) |
| 121 | + - name: upload pages artifact |
| 122 | + if: github.ref == 'refs/heads/main' |
| 123 | + uses: actions/upload-pages-artifact@v3 |
| 124 | + with: |
| 125 | + path: docs/dist |
| 126 | + |
| 127 | + deploy: |
| 128 | + if: github.ref == 'refs/heads/main' |
| 129 | + needs: check-and-build |
| 130 | + runs-on: ubuntu-latest |
| 131 | + permissions: |
| 132 | + contents: read |
| 133 | + pages: write |
| 134 | + id-token: write |
| 135 | + environment: |
| 136 | + name: github-pages |
| 137 | + url: ${{ steps.deployment.outputs.page_url }} |
| 138 | + steps: |
| 139 | + - name: deploy to GitHub Pages |
| 140 | + id: deployment |
| 141 | + uses: actions/deploy-pages@v4 |
0 commit comments