@@ -22,8 +22,61 @@ concurrency:
2222 cancel-in-progress : false
2323
2424jobs :
25+ detect-changes :
26+ runs-on : ubuntu-latest
27+ outputs :
28+ portal : ${{ steps.changes.outputs.portal }}
29+ standards : ${{ steps.changes.outputs.standards }}
30+ standards-list : ${{ steps.list-standards.outputs.standards }}
31+ packages : ${{ steps.changes.outputs.packages }}
32+ steps :
33+ - name : Checkout
34+ uses : actions/checkout@v4
35+ with :
36+ fetch-depth : 2
37+
38+ - name : Check for changes
39+ id : changes
40+ run : |
41+ # Check if portal files changed
42+ if git diff --name-only HEAD^ HEAD | grep -qE '^(portal/)'; then
43+ echo "portal=true" >> $GITHUB_OUTPUT
44+ else
45+ echo "portal=false" >> $GITHUB_OUTPUT
46+ fi
47+
48+ # Check if standards files changed
49+ if git diff --name-only HEAD^ HEAD | grep -qE '^(standards/)'; then
50+ echo "standards=true" >> $GITHUB_OUTPUT
51+ else
52+ echo "standards=false" >> $GITHUB_OUTPUT
53+ fi
54+
55+ # Check if packages changed (theme/preset) - triggers rebuild of everything
56+ if git diff --name-only HEAD^ HEAD | grep -qE '^(packages/|pnpm-lock.yaml|package.json)'; then
57+ echo "packages=true" >> $GITHUB_OUTPUT
58+ else
59+ echo "packages=false" >> $GITHUB_OUTPUT
60+ fi
61+
62+ - name : List standards to build
63+ id : list-standards
64+ run : |
65+ if [ "${{ steps.changes.outputs.packages }}" = "true" ]; then
66+ # If packages changed, build all standards
67+ echo "standards=ISBDM LRM FRBR isbd muldicat unimarc" >> $GITHUB_OUTPUT
68+ elif [ "${{ steps.changes.outputs.standards }}" = "true" ]; then
69+ # Get list of changed standards
70+ changed=$(git diff --name-only HEAD^ HEAD | grep '^standards/' | cut -d'/' -f2 | sort -u | tr '\n' ' ')
71+ echo "standards=$changed" >> $GITHUB_OUTPUT
72+ else
73+ echo "standards=" >> $GITHUB_OUTPUT
74+ fi
75+
2576 build-portal :
2677 runs-on : ubuntu-latest
78+ needs : detect-changes
79+ if : needs.detect-changes.outputs.portal == 'true' || needs.detect-changes.outputs.packages == 'true'
2780 steps :
2881 - name : Checkout
2982 uses : actions/checkout@v4
@@ -75,28 +128,49 @@ jobs:
75128
76129 build-standards :
77130 runs-on : ubuntu-latest
131+ needs : detect-changes
132+ if : needs.detect-changes.outputs.standards == 'true' || needs.detect-changes.outputs.packages == 'true'
78133 strategy :
79134 matrix :
80135 standard : [ISBDM, LRM, FRBR, isbd, muldicat, unimarc]
81136 steps :
137+ - name : Check if should build
138+ id : should-build
139+ run : |
140+ standards_list="${{ needs.detect-changes.outputs.standards-list }}"
141+
142+ # If packages changed, build all
143+ if [ "${{ needs.detect-changes.outputs.packages }}" = "true" ]; then
144+ echo "build=true" >> $GITHUB_OUTPUT
145+ # If this standard is in the changed list
146+ elif [[ " $standards_list " =~ " ${{ matrix.standard }} " ]]; then
147+ echo "build=true" >> $GITHUB_OUTPUT
148+ else
149+ echo "build=false" >> $GITHUB_OUTPUT
150+ fi
82151 - name : Checkout
152+ if : steps.should-build.outputs.build == 'true'
83153 uses : actions/checkout@v4
84154
85155 - name : Setup pnpm
156+ if : steps.should-build.outputs.build == 'true'
86157 uses : pnpm/action-setup@v4
87158
88159 - name : Setup Node.js
160+ if : steps.should-build.outputs.build == 'true'
89161 uses : actions/setup-node@v4
90162 with :
91163 node-version : ' 22'
92164 cache : ' pnpm'
93165
94166 - name : Get pnpm store directory
167+ if : steps.should-build.outputs.build == 'true'
95168 shell : bash
96169 run : |
97170 echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
98171
99172 - name : Setup pnpm cache
173+ if : steps.should-build.outputs.build == 'true'
100174 uses : actions/cache@v4
101175 with :
102176 path : ${{ env.STORE_PATH }}
@@ -105,22 +179,27 @@ jobs:
105179 ${{ runner.os }}-pnpm-store-
106180
107181 - name : Install dependencies
182+ if : steps.should-build.outputs.build == 'true'
108183 run : pnpm install --frozen-lockfile
109184
110185 - name : Build theme package
186+ if : steps.should-build.outputs.build == 'true'
111187 run : pnpm build:theme
112188
113189 - name : Build preset package
190+ if : steps.should-build.outputs.build == 'true'
114191 run : pnpm build:preset
115192
116193 - name : Build ${{ matrix.standard }}
194+ if : steps.should-build.outputs.build == 'true'
117195 run : pnpm exec docusaurus build standards/${{ matrix.standard }}
118196 env :
119197 BASE_URL : /standards-dev/${{ matrix.standard }}/
120198 NODE_ENV : production
121199 DOCS_ENV : dev
122200
123201 - name : Upload ${{ matrix.standard }} artifact
202+ if : steps.should-build.outputs.build == 'true'
124203 uses : actions/upload-artifact@v4
125204 with :
126205 name : ${{ matrix.standard }}-build
@@ -129,52 +208,67 @@ jobs:
129208
130209 deploy :
131210 runs-on : ubuntu-latest
132- needs : [build-portal, build-standards]
211+ needs : [detect-changes, build-portal, build-standards]
212+ if : always() && (needs.build-portal.result == 'success' || needs.build-standards.result == 'success' || needs.build-portal.result == 'skipped' || needs.build-standards.result == 'skipped')
133213 steps :
134214 - name : Create deployment directory
135215 run : mkdir -p deployment
136216
137217 - name : Download portal build
218+ if : needs.build-portal.result == 'success'
138219 uses : actions/download-artifact@v4
139220 with :
140221 name : portal-build
141222 path : deployment/
223+ continue-on-error : true
142224
143225 - name : Download ISBDM build
226+ if : needs.build-standards.result == 'success'
144227 uses : actions/download-artifact@v4
145228 with :
146229 name : ISBDM-build
147230 path : deployment/ISBDM
231+ continue-on-error : true
148232
149233 - name : Download LRM build
234+ if : needs.build-standards.result == 'success'
150235 uses : actions/download-artifact@v4
151236 with :
152237 name : LRM-build
153238 path : deployment/LRM
239+ continue-on-error : true
154240
155241 - name : Download FRBR build
242+ if : needs.build-standards.result == 'success'
156243 uses : actions/download-artifact@v4
157244 with :
158245 name : FRBR-build
159246 path : deployment/FRBR
247+ continue-on-error : true
160248
161249 - name : Download isbd build
250+ if : needs.build-standards.result == 'success'
162251 uses : actions/download-artifact@v4
163252 with :
164253 name : isbd-build
165254 path : deployment/isbd
255+ continue-on-error : true
166256
167257 - name : Download muldicat build
258+ if : needs.build-standards.result == 'success'
168259 uses : actions/download-artifact@v4
169260 with :
170261 name : muldicat-build
171262 path : deployment/muldicat
263+ continue-on-error : true
172264
173265 - name : Download unimarc build
266+ if : needs.build-standards.result == 'success'
174267 uses : actions/download-artifact@v4
175268 with :
176269 name : unimarc-build
177270 path : deployment/unimarc
271+ continue-on-error : true
178272
179273 - name : Create standards index
180274 run : |
0 commit comments