@@ -2,8 +2,7 @@ name: Docusaurus CI, Previews & Cleanup
22
33on :
44 push :
5- branches :
6- - master
5+ branches : [master]
76 pull_request :
87 types : [opened, synchronize, reopened, closed]
98
@@ -14,7 +13,44 @@ permissions:
1413 pull-requests : write
1514
1615jobs :
16+
17+ format-check :
18+ runs-on : ubuntu-latest
19+ steps :
20+ - uses : actions/checkout@v4
21+
22+ - uses : actions/setup-node@v4
23+ with :
24+ node-version : 22
25+
26+ - name : Install dependencies
27+ run : npm ci
28+
29+ - name : Check Formatting (Prettier)
30+ run : npm run format:check
31+
32+ lint-check :
33+ runs-on : ubuntu-latest
34+ steps :
35+ - uses : actions/checkout@v4
36+
37+ - uses : actions/setup-node@v4
38+ with :
39+ node-version : 22
40+
41+ - name : Install dependencies
42+ run : npm ci
43+
44+ - name : Lint Code
45+ run : npm run lint
46+
47+
48+ # ---------------------
49+ # BUILD JOB
50+ # Runs ONLY if lint + prettier succeed
51+ # ---------------------
1752 build :
53+ needs : [format-check, lint-check] # Dependencies
1854 if : github.event.action != 'closed'
1955 runs-on : ubuntu-latest
2056
3167
3268 - name : Install dependencies
3369 run : npm ci
34- - name : Check Formatting (Prettier)
35- run : npm run format:check
36-
37- - name : Lint Code (ESLint)
38- run : npm run lint
3970
4071 - name : Inject correct baseUrl into docusaurus.config.js
4172 id : inject
@@ -45,21 +76,11 @@ jobs:
4576 else
4677 BASE_URL="/${{ github.event.repository.name }}/"
4778 fi
48-
4979 echo "Using baseUrl=$BASE_URL"
5080 echo "baseUrl=$BASE_URL" >> $GITHUB_OUTPUT
5181
5282 sed -i "s|baseUrl: '.*'|baseUrl: '$BASE_URL'|" docusaurus.config.js
5383
54- - name : Comment injected baseUrl on PR
55- if : github.event_name == 'pull_request'
56- uses : marocchino/sticky-pull-request-comment@v2
57- with :
58- header : docusaurus-baseurl
59- message : |
60- 🛠 **Injected baseUrl**
61- ➤ `${{ steps.inject.outputs.baseUrl }}`
62-
6384 - name : Build Docusaurus site
6485 run : npm run build
6586
6990 name : docusaurus-build
7091 path : build
7192
93+
94+ # ---------------------
95+ # DEPLOY JOB
96+ # ---------------------
7297 deploy :
73- if : github.event.action != 'closed'
7498 needs : build
99+ if : github.event.action != 'closed'
75100 runs-on : ubuntu-latest
76101
77102 steps :
99124 publish_dir : ./build
100125 publish_branch : gh-pages
101126 destination_dir : ${{ steps.vars.outputs.destination_dir }}
102- keep_files : true # Keep other PR previews intact
127+ keep_files : true
103128
104129 - name : Comment preview link on PR
105130 if : github.event_name == 'pull_request'
@@ -110,6 +135,10 @@ jobs:
110135 🚀 **Docusaurus preview deployed!**
111136 🔗 [View Preview](${{ steps.vars.outputs.url }})
112137
138+
139+ # ---------------------
140+ # CLEANUP JOB
141+ # ---------------------
113142 cleanup :
114143 if : github.event_name == 'pull_request' && github.event.action == 'closed'
115144 runs-on : ubuntu-latest
0 commit comments