-
Notifications
You must be signed in to change notification settings - Fork 1
147 lines (128 loc) · 4.1 KB
/
Copy pathdocs.yml
File metadata and controls
147 lines (128 loc) · 4.1 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
name: Docs
"on":
pull_request:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
renderer-tests:
name: Test Dev Notes renderer (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.12"]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Run renderer tests
run: python -m unittest discover -s tests
validate:
name: Validate documentation
needs: renderer-tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements-docs.txt
- name: Check Dev Notes renderer syntax
run: python -m py_compile scripts/render-dev-notes.py
- name: Check navigation JavaScript syntax
run: node --check docs/javascripts/navigation-drawer.js
- name: Build documentation
run: scripts/build-docs.sh
- name: Verify generated documentation is committed
run: git diff --exit-code -- docs/dev-notes zensical.toml
- name: Upload production documentation
if: >-
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
github.event_name == 'workflow_dispatch')
uses: actions/upload-artifact@v7
with:
name: production-docs-${{ github.run_id }}
path: site
if-no-files-found: error
retention-days: 1
deploy:
name: Deploy documentation
if: >-
github.ref == 'refs/heads/main' &&
(github.event_name == 'push' ||
github.event_name == 'workflow_dispatch')
needs: validate
runs-on: ubuntu-latest
permissions:
actions: read
contents: write
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
concurrency:
group: github-pages
queue: max
steps:
- name: Check production revision is current
id: freshness
uses: actions/github-script@v8
with:
script: |
const { data: branch } = await github.rest.repos.getBranch({
owner: context.repo.owner,
repo: context.repo.repo,
branch: 'main',
});
const current = branch.commit.sha === context.sha;
core.setOutput('current', String(current));
if (!current) {
core.notice(`Skipping stale production revision ${context.sha}.`);
}
- name: Checkout deployment tooling context
if: steps.freshness.outputs.current == 'true'
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Download production documentation
if: steps.freshness.outputs.current == 'true'
uses: actions/download-artifact@v8
with:
name: production-docs-${{ github.run_id }}
path: site
- name: Update composite Pages branch
if: steps.freshness.outputs.current == 'true'
uses: JamesIves/github-pages-deploy-action@4a3abc783e1a24aeb44c16e869ad83caf6b4cc23 # v4.7.4
with:
branch: gh-pages
folder: site
clean-exclude: pr-preview
force: false
attempt-limit: 10
- name: Checkout composite Pages site
if: steps.freshness.outputs.current == 'true'
uses: actions/checkout@v7
with:
ref: gh-pages
path: published-site
persist-credentials: false
- name: Upload Pages artifact
if: steps.freshness.outputs.current == 'true'
uses: actions/upload-pages-artifact@v5
with:
path: published-site
- name: Deploy to GitHub Pages
if: steps.freshness.outputs.current == 'true'
id: deployment
uses: actions/deploy-pages@v5