Skip to content

Commit d80d389

Browse files
committed
git: fix workflow for dependency
1 parent c34e84e commit d80d389

File tree

1 file changed

+103
-16
lines changed

1 file changed

+103
-16
lines changed

.github/workflows/docs.yaml

Lines changed: 103 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,29 +148,30 @@ jobs:
148148
name: visualizer
149149
path: ui/dist
150150

151-
docs-build:
152-
name: "Build Docusaurus Site"
151+
# This job handles PR and push events, and depends on viz-build
152+
docs-build-pr-push:
153+
name: "Build Docusaurus Site (PR/Push)"
153154
runs-on: ubuntu-latest
154155
needs: [viz-build]
155-
# For workflow_run events, we don't need viz-build
156-
if: |
157-
github.event_name == 'pull_request' ||
158-
github.event_name == 'push' ||
159-
github.event_name == 'workflow_dispatch' ||
160-
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
156+
if: github.event_name == 'pull_request' || github.event_name == 'push' || github.event_name == 'workflow_dispatch'
161157
outputs:
162-
has_changes: ${{ steps.check_changes.outputs.has_changes || github.event_name == 'workflow_run' || github.event_name == 'workflow_dispatch' }}
158+
has_changes: ${{ steps.check_changes.outputs.has_changes || github.event_name == 'workflow_dispatch' }}
163159
steps:
164160
- name: 📥 Checkout repository
165161
uses: actions/checkout@v4
166162
with:
167163
fetch-depth: 2
168164

165+
- name: Debug workflow trigger info
166+
run: |
167+
echo "Event name: ${{ github.event_name }}"
168+
echo "Ref: ${{ github.ref }}"
169+
169170
- name: Check for site or visualizer changes
170171
id: check_changes
171172
run: |
172-
if [ "${{ github.event_name }}" == "workflow_run" ] || [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
173-
echo "Changes detected from formal-spec workflow or manual trigger"
173+
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
174+
echo "Changes from manual trigger"
174175
echo "has_changes=true" >> $GITHUB_OUTPUT
175176
else
176177
# For PR or push events, check for actual changes
@@ -203,20 +204,19 @@ jobs:
203204

204205
# Handle visualizer integration
205206
- name: 👁️ Unpack visualizer
206-
if: steps.check_changes.outputs.has_changes == 'true' && (github.event_name == 'pull_request' || github.event_name == 'push')
207+
if: steps.check_changes.outputs.has_changes == 'true'
207208
uses: actions/download-artifact@v4
208209
with:
209210
name: visualizer
210211
path: site/static/visualizer
211212

212-
# Download formal spec HTML - unified approach for all event types
213+
# Download formal spec HTML
213214
- name: 📥 Download formal spec HTML
214215
if: steps.check_changes.outputs.has_changes == 'true'
215216
uses: actions/download-artifact@v4
216217
continue-on-error: true
217218
with:
218219
name: formal-spec-html
219-
run-id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || '' }}
220220
path: formal-spec-html
221221

222222
- name: 📝 Update formal spec
@@ -271,13 +271,100 @@ jobs:
271271
path: |
272272
site/build/*
273273
274+
# This job handles workflow_run events from formal-spec-listener
275+
docs-build-workflow-run:
276+
name: "Build Docusaurus Site (Workflow Run)"
277+
runs-on: ubuntu-latest
278+
# No dependency on viz-build for workflow_run events
279+
if: github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'
280+
outputs:
281+
has_changes: "true"
282+
steps:
283+
- name: 📥 Checkout repository
284+
uses: actions/checkout@v4
285+
286+
- name: Debug workflow trigger info
287+
run: |
288+
echo "Event name: ${{ github.event_name }}"
289+
echo "Workflow run conclusion: ${{ github.event.workflow_run.conclusion }}"
290+
echo "Workflow run name: ${{ github.event.workflow_run.name }}"
291+
echo "Workflow run ID: ${{ github.event.workflow_run.id }}"
292+
echo "Ref: ${{ github.ref }}"
293+
294+
- name: 🛠️ Setup Node.js
295+
uses: actions/setup-node@v4
296+
with:
297+
node-version: 22
298+
cache: "yarn"
299+
cache-dependency-path: ./site/yarn.lock
300+
301+
- name: 📦 Install dependencies
302+
working-directory: site
303+
run: yarn install
304+
305+
# Download formal spec HTML specifically from the workflow run
306+
- name: 📥 Download formal spec HTML
307+
uses: actions/download-artifact@v4
308+
continue-on-error: true
309+
with:
310+
name: formal-spec-html
311+
run-id: ${{ github.event.workflow_run.id }}
312+
path: formal-spec-html
313+
314+
- name: 📝 Update formal spec
315+
run: |
316+
# Create formal spec directory if it doesn't exist
317+
mkdir -p site/static/formal-spec
318+
319+
# Check if we have files to copy
320+
if [ -z "$(ls -A formal-spec-html/ 2>/dev/null)" ]; then
321+
echo "No formal spec HTML files found - using placeholder"
322+
echo "<html><body><h1>Formal Specification</h1><p>Formal specification documentation is being updated. Please check back later.</p></body></html>" > site/static/formal-spec/index.html
323+
else
324+
# Copy the HTML files
325+
cp -r formal-spec-html/* site/static/formal-spec/
326+
fi
327+
328+
- name: 🔄 Enhance Agda documentation
329+
working-directory: site
330+
run: |
331+
# Process HTML files using the agda-web-docs-lib only if there are actual HTML files
332+
if [ -d "./static/formal-spec" ] && [ "$(find ./static/formal-spec -name '*.html' | grep -v index.html | wc -l)" -gt "0" ]; then
333+
NODE_OPTIONS="--max-old-space-size=16384" npx agda-web-docs-lib process ./static/formal-spec ./agda-docs.config.json
334+
else
335+
echo "No HTML files found in formal-spec directory, skipping enhancement"
336+
fi
337+
338+
- name: 🏗️ Build Docusaurus site
339+
working-directory: site
340+
run: |
341+
yarn build
342+
343+
- name: Verify Docusaurus build
344+
working-directory: site
345+
run: |
346+
if [ -z "$(ls -A build/)" ]; then
347+
echo "Error: Docusaurus build directory is empty"
348+
exit 1
349+
fi
350+
echo "Docusaurus build verified"
351+
ls -la build/
352+
353+
- name: 🚀 Upload Docusaurus build
354+
uses: actions/upload-artifact@v4
355+
with:
356+
name: docusaurus-build
357+
if-no-files-found: error
358+
path: |
359+
site/build/*
360+
274361
docs-publish:
275362
name: "Publish"
276363
if: |
277364
github.ref == 'refs/heads/main' &&
278-
needs.docs-build.outputs.has_changes == 'true'
365+
(needs.docs-build-pr-push.outputs.has_changes == 'true' || needs.docs-build-workflow-run.outputs.has_changes == 'true')
279366
runs-on: ubuntu-latest
280-
needs: docs-build
367+
needs: [docs-build-pr-push, docs-build-workflow-run]
281368
steps:
282369
- name: 📥 Download Docusaurus build
283370
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)