👷 Upgrade CI for docs (#642)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Sebastián Ramírez · committed by GitHub · parent 70d04f2 · Browse files · 2 files·+64 added−42 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+64 added−42 removed
- other:+64 added−42 removed
Provenance
- Commit
528db80- Tree
ad9096a- Author
Sebastián Ramírez <tiangolo@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
70d04f2
2 files changed+64 added−42 removed
modified:.github/workflows/build-docs.yml+50 added-31 removed
2 unmodified lines345678910111213789101112131415161718192021222324252627282930313233343536371638394041424344454647262728293031324849505152535455405657584359606146626364656667685369707156727374757661626364777879808182838485868788896667686970717290912 unmodified lines push: branches: - master pull_request: types: [opened, synchronize] workflow_dispatch: inputs: debug_enabled: description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false types: - opened - synchronizejobs: changes: runs-on: ubuntu-latest # Required permissions permissions: pull-requests: read # Set job outputs to values from filter step outputs: docs: ${{ steps.filter.outputs.docs }} steps: - uses: actions/checkout@v3 # For pull requests it's not necessary to checkout the code but for the main branch it is - uses: dorny/paths-filter@v2 id: filter with: filters: | docs: - README.md - docs/** - docs_src/** - pyproject.toml - mkdocs.yml - mkdocs.insiders.yml
build-docs: needs: - changes if: ${{ needs.changes.outputs.docs == 'true' }} runs-on: ubuntu-20.04 runs-on: ubuntu-latest steps: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: "3.7" # Allow debugging with tmate - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} with: limit-access-to-actor: true python-version: "3.11" - uses: actions/cache@v3 id: cache with: path: ${{ env.pythonLocation }} key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01 - name: Install Flit if: steps.cache.outputs.cache-hit != 'true' run: python3.7 -m pip install flit run: python -m pip install flit - name: Install docs extras if: steps.cache.outputs.cache-hit != 'true' run: python3.7 -m flit install --extras doc run: python -m flit install --extras doc - name: Install Material for MkDocs Insiders if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true' run: python3.7 -m pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git run: python -m pip install git+https://${{ secrets.TYPER_MKDOCS_MATERIAL_INSIDERS }}@github.com/squidfunk/mkdocs-material-insiders.git - uses: actions/cache@v3 with: key: mkdocs-cards-${{ github.ref }}-v1 path: .cache - name: Build Docs if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true run: python3.7 -m mkdocs build run: python -m mkdocs build - name: Build Docs with Insiders if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false run: python3.7 -m mkdocs build --config-file mkdocs.insiders.yml run: python -m mkdocs build --config-file mkdocs.insiders.yml - name: Zip docs run: bash ./scripts/zip-docs.sh - uses: actions/upload-artifact@v3 with: name: docs-zip path: ./site/docs.zip - name: Deploy to Netlify uses: nwtgck/actions-netlify@v2.0.0 name: docs-site path: ./site/**
# 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: - build-docs runs-on: ubuntu-latest steps: - name: Decide whether the needed jobs succeeded or failed uses: re-actors/alls-green@release/v1 with: publish-dir: './site' production-branch: master github-token: ${{ secrets.GITHUB_TOKEN }} enable-commit-comment: false env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} jobs: ${{ toJSON(needs) }} allowed-skips: build-docsmodified:.github/workflows/preview-docs.yml+14 added-11 removed
11234567891011101112131415161718192021222319242526272829243031262728293032333435363736383940414243444546474849name: Preview Docsname: Deploy Docson: workflow_run: workflows: - Build Docs types: - completed
jobs: preview-docs: runs-on: ubuntu-20.04 deploy-docs: runs-on: ubuntu-latest steps: - name: Dump GitHub context env: GITHUB_CONTEXT: ${{ toJson(github) }} run: echo "$GITHUB_CONTEXT" - uses: actions/checkout@v3 - name: Clean site run: | rm -rf ./site mkdir ./site - name: Download Artifact Docs id: download uses: dawidd6/action-download-artifact@v2.26.0 uses: dawidd6/action-download-artifact@v2.27.0 with: if_no_artifact_found: ignore github_token: ${{ secrets.GITHUB_TOKEN }} workflow: build-docs.yml run_id: ${{ github.event.workflow_run.id }} name: docs-zip name: docs-site path: ./site/ - name: Unzip docs run: | cd ./site unzip docs.zip rm -f docs.zip - name: Deploy to Netlify if: steps.download.outputs.found_artifact == 'true' id: netlify uses: nwtgck/actions-netlify@v2.0.0 with: publish-dir: './site' production-deploy: false production-deploy: ${{ github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'master' }} github-token: ${{ secrets.GITHUB_TOKEN }} enable-commit-comment: false env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} - name: Comment Deploy if: steps.netlify.outputs.deploy-url != '' uses: ./.github/actions/comment-docs-preview-in-pr with: token: ${{ secrets.GITHUB_TOKEN }} deploy_url: "${{ steps.netlify.outputs.deploy-url }}"