Skip to content

Commit e3adde2

Browse files
authored
ci: share the docs build action (#3874)
PR validation, nightly link checking, and docs publishing each had their own copy of the Astro setup and build steps. This moves that sequence into one local composite action and makes all three jobs run the same checks, asset fetch, build, and built-site tests. The workflow path filters now include the shared action, so changes to it exercise PR validation and the publishing path. The single `setup-node` pin is v7, superseding the three-copy bump in #3869. Tested with the full docs command sequence, Actionlint, YAML validation, and action metadata validation. > _This was written by Codex on behalf of @max-sixty_
1 parent 7ee9c62 commit e3adde2

4 files changed

Lines changed: 56 additions & 69 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: docs build
2+
description: Install, build, and verify the Astro documentation site
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js
8+
uses: actions/setup-node@v7
9+
with:
10+
node-version: 24
11+
cache: npm
12+
cache-dependency-path: docs/package-lock.json
13+
14+
- name: Install docs dependencies
15+
shell: bash
16+
run: npm ci
17+
working-directory: docs
18+
19+
- name: Fetch docs assets
20+
shell: bash
21+
env:
22+
GH_TOKEN: ${{ github.token }}
23+
run: |
24+
gh repo clone max-sixty/worktrunk-assets /tmp/worktrunk-assets -- --depth 1
25+
cp -r /tmp/worktrunk-assets/assets docs/public/
26+
27+
- name: Check docs source
28+
shell: bash
29+
run: npm run check && npm test
30+
working-directory: docs
31+
32+
- name: Build docs
33+
shell: bash
34+
run: npm run build
35+
working-directory: docs
36+
37+
- name: Test built site
38+
shell: bash
39+
run: npm run test:site
40+
working-directory: docs

‎.github/workflows/ci.yaml‎

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,10 @@ jobs:
191191
docs:
192192
- 'docs/**'
193193
- 'src/cli/mod.rs'
194+
- '.github/actions/docs-build/**'
195+
- '.github/workflows/ci.yaml'
196+
- '.github/workflows/nightly.yaml'
197+
- '.github/workflows/publish-docs.yaml'
194198
195199
msrv:
196200
runs-on: ubuntu-24.04
@@ -225,24 +229,5 @@ jobs:
225229
- name: 📂 Checkout code
226230
uses: actions/checkout@v7
227231

228-
- name: Setup Node.js
229-
uses: actions/setup-node@v6
230-
with:
231-
node-version: 24
232-
cache: npm
233-
cache-dependency-path: docs/package-lock.json
234-
235-
- name: Install docs dependencies
236-
run: npm ci
237-
working-directory: docs
238-
239-
- name: Fetch assets
240-
env:
241-
GH_TOKEN: ${{ github.token }}
242-
run: |
243-
gh repo clone max-sixty/worktrunk-assets /tmp/worktrunk-assets -- --depth 1
244-
cp -r /tmp/worktrunk-assets/assets docs/public/
245-
246232
- name: 🕷️ Check and build docs
247-
run: npm run check && npm test && npm run build && npm run test:site
248-
working-directory: docs
233+
uses: ./.github/actions/docs-build

‎.github/workflows/nightly.yaml‎

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -357,13 +357,11 @@ jobs:
357357
run: cargo test --test integration crate_io_archive_builds_and_versions_without_git -- --ignored
358358

359359
link-check:
360-
# The pre-commit `lychee-system` hook (manual stage) over every tracked
361-
# .md/.txt file, resolving local routes against the built Astro site. It
362-
# lives here, not in PR CI: link health depends on the outside world
363-
# (429s, bot-blocking, transient outages), so it was the flakiest PR
364-
# check — and link rot isn't PR-correlated anyway; links break when
365-
# external sites change, not when code does. A failure opens the
366-
# nightly-failure issue instead of reddening an unrelated PR.
360+
# The shared docs action verifies and builds the site before the pre-commit
361+
# `lychee-system` hook checks every tracked .md/.txt file. Lychee remains in
362+
# the nightly workflow rather than required PR CI because external link
363+
# health depends on 429s, bot-blocking, and transient outages. A scheduled
364+
# docs or link failure opens the nightly-failure issue.
367365
needs: gate
368366
if: needs.gate.outputs.run == 'true'
369367
runs-on: ubuntu-24.04
@@ -374,27 +372,8 @@ jobs:
374372
- name: 📂 Checkout code
375373
uses: actions/checkout@v7
376374

377-
- name: Setup Node.js
378-
uses: actions/setup-node@v6
379-
with:
380-
node-version: 24
381-
cache: npm
382-
cache-dependency-path: docs/package-lock.json
383-
384-
- name: Install docs dependencies
385-
run: npm ci
386-
working-directory: docs
387-
388-
- name: Fetch docs assets
389-
env:
390-
GH_TOKEN: ${{ github.token }}
391-
run: |
392-
gh repo clone max-sixty/worktrunk-assets /tmp/worktrunk-assets -- --depth 1
393-
cp -r /tmp/worktrunk-assets/assets docs/public/
394-
395-
- name: Build docs
396-
run: npm run build
397-
working-directory: docs
375+
- name: 🕷️ Check and build docs
376+
uses: ./.github/actions/docs-build
398377

399378
- name: Install lychee
400379
uses: baptiste0928/cargo-install@v3

‎.github/workflows/publish-docs.yaml‎

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
paths:
99
- 'docs/**'
1010
- 'src/cli/mod.rs'
11+
- '.github/actions/docs-build/**'
12+
- '.github/workflows/publish-docs.yaml'
1113
workflow_dispatch:
1214

1315
concurrency:
@@ -22,27 +24,8 @@ jobs:
2224
- name: 📂 Checkout code
2325
uses: actions/checkout@v7
2426

25-
- name: Setup Node.js
26-
uses: actions/setup-node@v6
27-
with:
28-
node-version: 24
29-
cache: npm
30-
cache-dependency-path: docs/package-lock.json
31-
32-
- name: Install docs dependencies
33-
run: npm ci
34-
working-directory: docs
35-
36-
- name: Fetch assets
37-
env:
38-
GH_TOKEN: ${{ github.token }}
39-
run: |
40-
gh repo clone max-sixty/worktrunk-assets /tmp/worktrunk-assets -- --depth 1
41-
cp -r /tmp/worktrunk-assets/assets docs/public/
42-
43-
- name: 🕷️ Build docs
44-
run: npm run check && npm test && npm run build && npm run test:site
45-
working-directory: docs
27+
- name: 🕷️ Check and build docs
28+
uses: ./.github/actions/docs-build
4629

4730
- uses: actions/upload-pages-artifact@v5
4831
with:

0 commit comments

Comments
 (0)