Skip to content

Commit a21d5c8

Browse files
authored
👷‍♂️ Upgrade CI for docs (#628)
1 parent 02bd7eb commit a21d5c8

File tree

5 files changed

+59
-160
lines changed

5 files changed

+59
-160
lines changed

.github/actions/watch-previews/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

.github/actions/watch-previews/action.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

.github/actions/watch-previews/app/main.py

Lines changed: 0 additions & 102 deletions
This file was deleted.

.github/workflows/build-docs.yml

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,34 @@ on:
77
types:
88
- opened
99
- synchronize
10-
workflow_dispatch:
11-
inputs:
12-
debug_enabled:
13-
description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)'
14-
required: false
15-
default: false
1610
jobs:
11+
changes:
12+
runs-on: ubuntu-latest
13+
# Required permissions
14+
permissions:
15+
pull-requests: read
16+
# Set job outputs to values from filter step
17+
outputs:
18+
docs: ${{ steps.filter.outputs.docs }}
19+
steps:
20+
- uses: actions/checkout@v3
21+
# For pull requests it's not necessary to checkout the code but for the main branch it is
22+
- uses: dorny/paths-filter@v2
23+
id: filter
24+
with:
25+
filters: |
26+
docs:
27+
- README.md
28+
- docs/**
29+
- docs_src/**
30+
- pyproject.toml
31+
- mkdocs.yml
32+
- mkdocs.insiders.yml
33+
1734
build-docs:
35+
needs:
36+
- changes
37+
if: ${{ needs.changes.outputs.docs == 'true' }}
1838
runs-on: ubuntu-latest
1939
steps:
2040
- name: Dump GitHub context
@@ -26,18 +46,12 @@ jobs:
2646
uses: actions/setup-python@v4
2747
with:
2848
python-version: "3.11"
29-
# Allow debugging with tmate
30-
- name: Setup tmate session
31-
uses: mxschmitt/action-tmate@v3
32-
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }}
33-
with:
34-
limit-access-to-actor: true
3549
- uses: actions/cache@v3
3650
id: cache
3751
with:
3852
path: ${{ env.pythonLocation }}
39-
key: ${{ runner.os }}-python-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-root-docs-v2
40-
- name: Install poetry
53+
key: ${{ runner.os }}-python-docs-${{ env.pythonLocation }}-${{ hashFiles('pyproject.toml') }}-v01
54+
- name: Install Poetry
4155
if: steps.cache.outputs.cache-hit != 'true'
4256
run: |
4357
python -m pip install --upgrade pip
@@ -61,19 +75,20 @@ jobs:
6175
- name: Build Docs with Insiders
6276
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.fork == false
6377
run: python -m poetry run mkdocs build --config-file mkdocs.insiders.yml
64-
- name: Zip docs
65-
run: python -m poetry run bash ./scripts/zip-docs.sh
6678
- uses: actions/upload-artifact@v3
6779
with:
68-
name: docs-zip
69-
path: ./site/docs.zip
70-
- name: Deploy to Netlify
71-
uses: nwtgck/[email protected]
80+
name: docs-site
81+
path: ./site/**
82+
83+
# https://github.com/marketplace/actions/alls-green#why
84+
docs-all-green: # This job does nothing and is only used for the branch protection
85+
if: always()
86+
needs:
87+
- build-docs
88+
runs-on: ubuntu-latest
89+
steps:
90+
- name: Decide whether the needed jobs succeeded or failed
91+
uses: re-actors/alls-green@release/v1
7292
with:
73-
publish-dir: './site'
74-
production-branch: main
75-
github-token: ${{ secrets.GITHUB_TOKEN }}
76-
enable-commit-comment: false
77-
env:
78-
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
79-
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
93+
jobs: ${{ toJSON(needs) }}
94+
allowed-skips: build-docs
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
name: Preview Docs
1+
name: Deploy Docs
22
on:
33
workflow_run:
44
workflows:
55
- Build Docs
6-
types:
6+
types:
77
- completed
88

99
jobs:
10-
preview-docs:
11-
runs-on: ubuntu-20.04
10+
deploy-docs:
11+
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/[email protected]
13+
- name: Dump GitHub context
14+
env:
15+
GITHUB_CONTEXT: ${{ toJson(github) }}
16+
run: echo "$GITHUB_CONTEXT"
17+
- uses: actions/checkout@v3
1418
- name: Clean site
1519
run: |
1620
rm -rf ./site
1721
mkdir ./site
1822
- name: Download Artifact Docs
19-
uses: dawidd6/[email protected]
23+
id: download
24+
uses: dawidd6/[email protected]
2025
with:
26+
if_no_artifact_found: ignore
2127
github_token: ${{ secrets.GITHUB_TOKEN }}
2228
workflow: build-docs.yml
2329
run_id: ${{ github.event.workflow_run.id }}
24-
name: docs-zip
30+
name: docs-site
2531
path: ./site/
26-
- name: Unzip docs
27-
run: |
28-
cd ./site
29-
unzip docs.zip
30-
rm -f docs.zip
3132
- name: Deploy to Netlify
33+
if: steps.download.outputs.found_artifact == 'true'
3234
id: netlify
33-
uses: nwtgck/actions-netlify@v1.1.5
35+
uses: nwtgck/actions-netlify@v2.0.0
3436
with:
3537
publish-dir: './site'
36-
production-deploy: false
38+
production-deploy: ${{ github.event.workflow_run.head_repository.full_name == github.repository && github.event.workflow_run.head_branch == 'main' }}
3739
github-token: ${{ secrets.GITHUB_TOKEN }}
3840
enable-commit-comment: false
3941
env:
4042
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
4143
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
4244
- name: Comment Deploy
45+
if: steps.netlify.outputs.deploy-url != ''
4346
uses: ./.github/actions/comment-docs-preview-in-pr
4447
with:
4548
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)