-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (144 loc) · 4.7 KB
/
Copy pathdeploy.yml
File metadata and controls
168 lines (144 loc) · 4.7 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# Build and deploy docs.sqlc.dev to GitHub Pages.
#
# The published tree (see README "URL scheme"):
#
# /en/latest/ Fumadocs build of sqlc-dev/sqlc@main docs/
# /en/vX.Y.Z/ legacy snapshots (legacy-versions.json) rebuilt with
# Sphinx from each tag's own docs/ + pinned
# requirements.txt, exactly as Read the Docs built them,
# with an "old version" banner injected per page
# /en/stable/ redirect stubs into the newest legacy snapshot
# /, /en/ redirects to /en/latest/
#
# Legacy snapshots are immutable, so their HTML is cached per tag; a cache
# miss (first run, or eviction) rebuilds from source in ~2 minutes. Bump
# CACHE_EPOCH to force a rebuild of every snapshot (e.g. after changing
# the Sphinx build steps below).
name: Deploy
on:
push:
branches: [main]
# Content pushes to sqlc-dev/sqlc docs/ (a workflow there sends this).
repository_dispatch:
types: [docs-updated]
# Safety net: pick up content changes even if no dispatch arrived.
schedule:
- cron: '23 5 * * *'
workflow_dispatch:
permissions:
contents: read
# One deploy at a time; a queued run supersedes anything else waiting.
concurrency:
group: deploy-pages
cancel-in-progress: false
env:
CACHE_EPOCH: 1
jobs:
# Fumadocs build of the current docs (/en/latest) + domain-root redirects.
latest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check out sqlc docs
uses: actions/checkout@v4
with:
repository: sqlc-dev/sqlc
path: .cache/sqlc
sparse-checkout: docs
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Ingest
run: node scripts/ingest.mjs --src .cache/sqlc/docs
- name: Build
run: npm run build
- uses: actions/upload-artifact@v4
with:
name: site-latest
path: |
out/
out-root/
retention-days: 1
# The legacy snapshot tags, read from legacy-versions.json.
versions:
runs-on: ubuntu-latest
outputs:
sphinx: ${{ steps.read.outputs.sphinx }}
steps:
- uses: actions/checkout@v4
- id: read
run: echo "sphinx=$(jq -c .sphinx legacy-versions.json)" >> "$GITHUB_OUTPUT"
# One Sphinx build per legacy tag, exactly as Read the Docs built it:
# the tag's own docs/ directory, conf.py, and fully pinned
# requirements.txt. Python 3.11 is what RTD's config specified for the
# newest tags and builds every older toolchain back to Sphinx 3.4 too.
sphinx:
needs: versions
runs-on: ubuntu-latest
strategy:
matrix:
version: ${{ fromJSON(needs.versions.outputs.sphinx) }}
steps:
- name: Restore snapshot cache
id: cache
uses: actions/cache@v4
with:
path: html
key: sphinx-html-${{ matrix.version }}-${{ env.CACHE_EPOCH }}
- name: Check out sqlc ${{ matrix.version }}
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/checkout@v4
with:
repository: sqlc-dev/sqlc
ref: ${{ matrix.version }}
path: sqlc
sparse-checkout: docs
- uses: actions/setup-python@v5
if: steps.cache.outputs.cache-hit != 'true'
with:
python-version: '3.11'
- name: Build with Sphinx
if: steps.cache.outputs.cache-hit != 'true'
run: |
python -m venv .venv
.venv/bin/pip install -r sqlc/docs/requirements.txt
.venv/bin/sphinx-build -b html -d .doctrees sqlc/docs html
- uses: actions/upload-artifact@v4
with:
name: sphinx-${{ matrix.version }}
path: html
retention-days: 1
# Assemble the full tree and publish it.
deploy:
needs: [latest, sphinx]
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- uses: actions/checkout@v4
- name: Download latest build
uses: actions/download-artifact@v4
with:
name: site-latest
path: _artifacts/latest
- name: Download Sphinx snapshots
uses: actions/download-artifact@v4
with:
pattern: sphinx-*
path: _artifacts/sphinx
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Assemble site
run: node scripts/assemble-site.mjs --latest _artifacts/latest --sphinx _artifacts/sphinx --out _site
- uses: actions/upload-pages-artifact@v3
with:
path: _site
- id: deployment
uses: actions/deploy-pages@v4