|
| 1 | +name: Build and publish docs |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pages: write |
| 6 | + id-token: write |
| 7 | + |
| 8 | +concurrency: |
| 9 | + # Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 10 | + # However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 11 | + group: pages |
| 12 | + cancel-in-progress: false |
| 13 | + |
| 14 | +on: |
| 15 | + workflow_run: |
| 16 | + workflows: [Python Tests] |
| 17 | + types: |
| 18 | + - completed |
| 19 | + branches: |
| 20 | + - main |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + build-and-publish-docs: |
| 25 | + if: ${{ github.event.workflow_run.conclusion == 'success' }} |
| 26 | + runs-on: ubuntu-latest |
| 27 | + environment: |
| 28 | + name: github-pages |
| 29 | + url: ${{ steps.deployment.outputs.page_url }} |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@v5 |
| 32 | + - name: Install uv |
| 33 | + uses: astral-sh/setup-uv@v7 |
| 34 | + with: |
| 35 | + enable-cache: true |
| 36 | + - name: Set up Python |
| 37 | + uses: actions/setup-python@v6 |
| 38 | + with: |
| 39 | + python-version-file: pyproject.toml |
| 40 | + - name: Install the project |
| 41 | + run: uv sync --only-group docs |
| 42 | + - name: Build docs |
| 43 | + run: | |
| 44 | + APP_MODULE_NAME=$(ls src -U | head -1) # Get the first module name in the src directory |
| 45 | + uv run pdoc src/"$APP_MODULE_NAME" -o docs_build -t docs/pdoc-theme --docformat google |
| 46 | + - name: Setup Pages |
| 47 | + uses: actions/configure-pages@v5 |
| 48 | + - name: Upload artifact |
| 49 | + uses: actions/upload-pages-artifact@v4 |
| 50 | + with: |
| 51 | + path: ./docs_build |
| 52 | + - name: Deploy to GitHub Pages |
| 53 | + id: deployment |
| 54 | + uses: actions/deploy-pages@v4 |
| 55 | + - name: Deploy to Cloudflare Pages |
| 56 | + id: cloudflare-deployment |
| 57 | + uses: cloudflare/wrangler-action@v3 |
| 58 | + with: |
| 59 | + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} |
| 60 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 61 | + command: pages deploy docs_build/ --project-name=styxpodman --branch=main |
0 commit comments