Skip to content

Commit 3efded7

Browse files
authored
fix(docs): enforce Node.js >=20 and upgrade Docusaurus to 3.9.2 (#437)
* fix(docs): enforce Node.js >=20 and upgrade Docusaurus to 3.9.2 * build(ci): enable docs workflow on PRs and use Node 20 * build(ci): add PR preview workflow * fix(ci): correct pull_request trigger type to synchronize * fix(ci): use pull_request_target for preview deployment permissions
1 parent 0982c3d commit 3efded7

File tree

6 files changed

+114
-683
lines changed

6 files changed

+114
-683
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
paths:
88
- 'docs/**'
9+
pull_request:
10+
paths:
11+
- 'docs/**'
912
workflow_dispatch:
1013

1114
permissions:
@@ -22,7 +25,7 @@ jobs:
2225
- uses: actions/checkout@v4
2326
- uses: actions/setup-node@v4
2427
with:
25-
node-version: 18
28+
node-version: 20
2629
cache: npm
2730
cache-dependency-path: docs/package-lock.json
2831

@@ -33,6 +36,7 @@ jobs:
3336
run: npm run build
3437

3538
- name: Deploy to GitHub Pages
39+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
3640
uses: peaceiris/actions-gh-pages@v3
3741
with:
3842
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/preview-docs.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy PR Preview
2+
3+
on:
4+
pull_request_target:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- closed
10+
paths:
11+
- 'docs/**'
12+
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
issues: write
17+
18+
jobs:
19+
deploy-preview:
20+
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
working-directory: docs
24+
steps:
25+
- uses: actions/checkout@v4
26+
with:
27+
ref: ${{ github.event.pull_request.head.sha }}
28+
29+
- uses: actions/setup-node@v4
30+
with:
31+
node-version: 20
32+
cache: npm
33+
cache-dependency-path: docs/package-lock.json
34+
35+
- name: Install dependencies
36+
run: npm ci
37+
38+
- name: Deploy preview
39+
uses: rossjrw/pr-preview-action@v1
40+
with:
41+
source_dir: docs/build
42+
preview_branch: gh-pages
43+
umbrella_dir: pr-preview
44+
action: auto
45+
# We need to build the site within the action context or before
46+
# rossjrw action can run a build command, but it's often easier to run the build ourselves
47+
# provided we can set the env var.
48+
# Actually, the action supports a 'build_script' input.
49+
build_script: npm run build
50+
# We need to pass the BASE_URL env var to the build script.
51+
# The action doesn't natively expose a way to inject env vars into the build_script
52+
# easily unless we wrap it or use the 'env' map at the step level.
53+
env:
54+
# The action calculates the preview URL. We need to construct the matching Base URL.
55+
# Default format is: /<umbrella_dir>/<pr_number>/
56+
# But we are deployed at /OpenGIN/. So it will be /OpenGIN/pr-preview/<pr_number>/
57+
BASE_URL: /OpenGIN/pr-preview/${{ github.event.number }}/

docs/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
20

docs/docusaurus.config.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ const config = {
1414
tagline: 'Open General Information Network',
1515
favicon: 'img/opengin_blue.png',
1616

17+
// Future flags, see https://docusaurus.io/docs/api/docusaurus-config#future
18+
future: {
19+
v4: true, // Improve compatibility with the upcoming Docusaurus v4
20+
},
1721

1822

1923
// Set the production url of your site here
2024
url: 'https://LDFLK.github.io',
2125
// Set the /<baseUrl>/ pathname under which your site is served
2226
// For GitHub pages deployment, it is often '/<projectName>/'
23-
baseUrl: '/OpenGIN/',
27+
baseUrl: process.env.BASE_URL || '/OpenGIN/',
2428

2529
// GitHub pages deployment config.
2630
// If you aren't using GitHub pages, you don't need these.

0 commit comments

Comments
 (0)