mirror of https://github.com/tiangolo/fastapi.git
👷 Build and deploy docs only on docs changes (#9728)
This commit is contained in:
parent
4721405ef7
commit
42d0d6e4a5
|
|
@ -4,9 +4,33 @@ on:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [opened, synchronize]
|
types:
|
||||||
|
- opened
|
||||||
|
- synchronize
|
||||||
jobs:
|
jobs:
|
||||||
|
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 master it is
|
||||||
|
- uses: dorny/paths-filter@v2
|
||||||
|
id: filter
|
||||||
|
with:
|
||||||
|
filters: |
|
||||||
|
docs:
|
||||||
|
- README.md
|
||||||
|
- docs/**
|
||||||
|
- docs_src/**
|
||||||
|
- requirements-docs.txt
|
||||||
build-docs:
|
build-docs:
|
||||||
|
needs: changes
|
||||||
|
if: ${{ needs.changes.outputs.docs == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Dump GitHub context
|
- name: Dump GitHub context
|
||||||
|
|
|
||||||
|
|
@ -16,19 +16,23 @@ jobs:
|
||||||
rm -rf ./site
|
rm -rf ./site
|
||||||
mkdir ./site
|
mkdir ./site
|
||||||
- name: Download Artifact Docs
|
- name: Download Artifact Docs
|
||||||
|
id: download
|
||||||
uses: dawidd6/action-download-artifact@v2.27.0
|
uses: dawidd6/action-download-artifact@v2.27.0
|
||||||
with:
|
with:
|
||||||
|
if_no_artifact_found: ignore
|
||||||
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-zip
|
||||||
path: ./site/
|
path: ./site/
|
||||||
- name: Unzip docs
|
- name: Unzip docs
|
||||||
|
if: steps.download.outputs.found_artifact == 'true'
|
||||||
run: |
|
run: |
|
||||||
cd ./site
|
cd ./site
|
||||||
unzip docs.zip
|
unzip docs.zip
|
||||||
rm -f docs.zip
|
rm -f docs.zip
|
||||||
- name: Deploy to Netlify
|
- name: Deploy to Netlify
|
||||||
|
if: steps.download.outputs.found_artifact == 'true'
|
||||||
id: netlify
|
id: netlify
|
||||||
uses: nwtgck/actions-netlify@v2.0.0
|
uses: nwtgck/actions-netlify@v2.0.0
|
||||||
with:
|
with:
|
||||||
|
|
@ -40,6 +44,7 @@ jobs:
|
||||||
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
|
||||||
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
|
||||||
- name: Comment Deploy
|
- name: Comment Deploy
|
||||||
|
if: steps.netlify.outputs.deploy-url != ''
|
||||||
uses: ./.github/actions/comment-docs-preview-in-pr
|
uses: ./.github/actions/comment-docs-preview-in-pr
|
||||||
with:
|
with:
|
||||||
token: ${{ secrets.FASTAPI_PREVIEW_DOCS_COMMENT_DEPLOY }}
|
token: ${{ secrets.FASTAPI_PREVIEW_DOCS_COMMENT_DEPLOY }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue