Repository navigation
93 lines (88 loc) · 3.01 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
93 lines (88 loc) · 3.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Deploy API docs
on:
workflow_run:
workflows: ['Build and publish docs']
types: [completed]
workflow_dispatch:
push:
branches: [main]
paths:
- 'api-docs/**'
- 'scripts/generate_api_docs.py'
- 'scripts/generate_versioned_api_docs.py'
- 'scripts/docs_versions.py'
- 'scripts/promote_docs_release.py'
- 'requirements-dev.txt'
- '.github/workflows/publish-docs.yml'
- '.github/workflows/deploy-docs.yml'
permissions:
contents: read
# Coalesce publications, not promotions. Every admitted run builds current main
# after entering this group, so replacement of pending events cannot lose state.
concurrency:
group: >-
${{ (github.event_name != 'workflow_run' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_repository.full_name == github.repository)) &&
'github-pages' || format('docs-ignored-{0}', github.run_id) }}
cancel-in-progress: false
jobs:
build:
if: >-
(github.event_name != 'workflow_run' ||
(github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.head_repository.full_name == github.repository))
runs-on: ubuntu-latest
outputs:
revision: ${{ steps.source.outputs.revision }}
steps:
- uses: actions/checkout@v4
with:
filter: tree:0
fetch-depth: 0
ref: main
persist-credentials: false
- id: source
run: echo "revision=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-python@v5
with:
python-version: "3.10"
cache: pip
- name: Install documentation dependencies
run: python -m pip install -r requirements-dev.txt
- name: Build exact release sources with current tooling
env:
GITHUB_TOKEN: ${{ github.token }}
run: python scripts/generate_versioned_api_docs.py
- uses: actions/upload-pages-artifact@v3
with:
path: api-docs/_build/versioned/
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Reject obsolete build
id: current
env:
GH_TOKEN: ${{ github.token }}
REPOSITORY: ${{ github.repository }}
BUILT_REVISION: ${{ needs.build.outputs.revision }}
run: |
latest=$(gh api "repos/$REPOSITORY/commits/main" --jq .sha)
if [[ "$latest" == "$BUILT_REVISION" ]]; then
echo "publish=true" >> "$GITHUB_OUTPUT"
else
echo "::notice::Skipping obsolete build; a queued publication builds current main. Manually dispatch if only unrelated paths changed."
fi
- uses: actions/configure-pages@v5
if: steps.current.outputs.publish == 'true'
- uses: actions/deploy-pages@v4
if: steps.current.outputs.publish == 'true'
id: deployment