committed by
GitHub
5 changed files with 142 additions and 113 deletions
@ -23,15 +23,45 @@ jobs: |
|||||
id: filter |
id: filter |
||||
with: |
with: |
||||
filters: | |
filters: | |
||||
docs: |
docs: |
||||
- README.md |
- README.md |
||||
- docs/** |
- docs/** |
||||
- docs_src/** |
- docs_src/** |
||||
- requirements-docs.txt |
- requirements-docs.txt |
||||
|
langs: |
||||
|
needs: |
||||
|
- changes |
||||
|
runs-on: ubuntu-latest |
||||
|
outputs: |
||||
|
langs: ${{ steps.show-langs.outputs.langs }} |
||||
|
steps: |
||||
|
- uses: actions/checkout@v3 |
||||
|
- name: Set up Python |
||||
|
uses: actions/setup-python@v4 |
||||
|
with: |
||||
|
python-version: "3.11" |
||||
|
- uses: actions/cache@v3 |
||||
|
id: cache |
||||
|
with: |
||||
|
path: ${{ env.pythonLocation }} |
||||
|
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml', 'requirements-docs.txt') }}-v03 |
||||
|
- name: Install docs extras |
||||
|
if: steps.cache.outputs.cache-hit != 'true' |
||||
|
run: pip install -r requirements-docs.txt |
||||
|
- name: Export Language Codes |
||||
|
id: show-langs |
||||
|
run: | |
||||
|
echo "langs=$(python ./scripts/docs.py langs-json)" >> $GITHUB_OUTPUT |
||||
|
|
||||
build-docs: |
build-docs: |
||||
needs: changes |
needs: |
||||
|
- changes |
||||
|
- langs |
||||
if: ${{ needs.changes.outputs.docs == 'true' }} |
if: ${{ needs.changes.outputs.docs == 'true' }} |
||||
runs-on: ubuntu-latest |
runs-on: ubuntu-latest |
||||
|
strategy: |
||||
|
matrix: |
||||
|
lang: ${{ fromJson(needs.langs.outputs.langs) }} |
||||
steps: |
steps: |
||||
- name: Dump GitHub context |
- name: Dump GitHub context |
||||
env: |
env: |
||||
@ -53,21 +83,24 @@ jobs: |
|||||
- name: Install Material for MkDocs Insiders |
- 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' |
if: ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false ) && steps.cache.outputs.cache-hit != 'true' |
||||
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git |
run: pip install git+https://${{ secrets.ACTIONS_TOKEN }}@github.com/squidfunk/mkdocs-material-insiders.git |
||||
|
- name: Update Languages |
||||
|
run: python ./scripts/docs.py update-languages |
||||
- name: Build Docs |
- name: Build Docs |
||||
run: python ./scripts/docs.py build-all |
run: python ./scripts/docs.py build-lang ${{ matrix.lang }} |
||||
- name: Zip docs |
|
||||
run: bash ./scripts/zip-docs.sh |
|
||||
- uses: actions/upload-artifact@v3 |
- uses: actions/upload-artifact@v3 |
||||
with: |
with: |
||||
name: docs-zip |
name: docs-site |
||||
path: ./site/docs.zip |
path: ./site/** |
||||
- name: Deploy to Netlify |
|
||||
uses: nwtgck/[email protected] |
# 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: |
with: |
||||
publish-dir: './site' |
jobs: ${{ toJSON(needs) }} |
||||
production-branch: master |
allowed-skips: build-docs |
||||
github-token: ${{ secrets.FASTAPI_BUILD_DOCS_NETLIFY }} |
|
||||
enable-commit-comment: false |
|
||||
env: |
|
||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
|
||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
|
||||
|
@ -1,4 +1,4 @@ |
|||||
name: Preview Docs |
name: Deploy Docs |
||||
on: |
on: |
||||
workflow_run: |
workflow_run: |
||||
workflows: |
workflows: |
||||
@ -7,9 +7,13 @@ on: |
|||||
- completed |
- completed |
||||
|
|
||||
jobs: |
jobs: |
||||
preview-docs: |
deploy-docs: |
||||
runs-on: ubuntu-latest |
runs-on: ubuntu-latest |
||||
steps: |
steps: |
||||
|
- name: Dump GitHub context |
||||
|
env: |
||||
|
GITHUB_CONTEXT: ${{ toJson(github) }} |
||||
|
run: echo "$GITHUB_CONTEXT" |
||||
- uses: actions/checkout@v3 |
- uses: actions/checkout@v3 |
||||
- name: Clean site |
- name: Clean site |
||||
run: | |
run: | |
||||
@ -23,21 +27,15 @@ jobs: |
|||||
github_token: ${{ secrets.FASTAPI_PREVIEW_DOCS_DOWNLOAD_ARTIFACTS }} |
github_token: ${{ secrets.FASTAPI_PREVIEW_DOCS_DOWNLOAD_ARTIFACTS }} |
||||
workflow: build-docs.yml |
workflow: build-docs.yml |
||||
run_id: ${{ github.event.workflow_run.id }} |
run_id: ${{ github.event.workflow_run.id }} |
||||
name: docs-zip |
name: docs-site |
||||
path: ./site/ |
path: ./site/ |
||||
- name: Unzip docs |
|
||||
if: steps.download.outputs.found_artifact == 'true' |
|
||||
run: | |
|
||||
cd ./site |
|
||||
unzip docs.zip |
|
||||
rm -f docs.zip |
|
||||
- name: Deploy to Netlify |
- name: Deploy to Netlify |
||||
if: steps.download.outputs.found_artifact == 'true' |
if: steps.download.outputs.found_artifact == 'true' |
||||
id: netlify |
id: netlify |
||||
uses: nwtgck/[email protected] |
uses: nwtgck/[email protected] |
||||
with: |
with: |
||||
publish-dir: './site' |
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.FASTAPI_PREVIEW_DOCS_NETLIFY }} |
github-token: ${{ secrets.FASTAPI_PREVIEW_DOCS_NETLIFY }} |
||||
enable-commit-comment: false |
enable-commit-comment: false |
||||
env: |
env: |
@ -1,11 +0,0 @@ |
|||||
#!/usr/bin/env bash |
|
||||
|
|
||||
set -x |
|
||||
set -e |
|
||||
|
|
||||
cd ./site |
|
||||
|
|
||||
if [ -f docs.zip ]; then |
|
||||
rm -rf docs.zip |
|
||||
fi |
|
||||
zip -r docs.zip ./ |
|
Loading…
Reference in new issue