Skip to content

Commit a2f115f

Browse files
committed
fixup! feat(ci): add lychee broken link checker and stage-and-check job
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
1 parent b42ff8c commit a2f115f

1 file changed

Lines changed: 59 additions & 23 deletions

File tree

.github/workflows/sphinxbuild.yml

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -328,25 +328,18 @@ jobs:
328328
echo "Validation structure ready:"
329329
find full-context -type d -maxdepth 2
330330
331-
- name: Check for broken links with lychee
332-
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
331+
# ========================================================================
332+
# UPLOAD VALIDATION CONTEXT FOR LINK CHECK JOB
333+
# ========================================================================
334+
# The full-context folder is uploaded so the link-check job (which runs
335+
# in parallel with deploy) can download it and run lychee there.
336+
# ========================================================================
337+
- name: Upload full validation context
338+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
333339
with:
334-
fail: true
335-
token: ${{ secrets.GITHUB_TOKEN }}
336-
jobSummary: true
337-
args: |
338-
--root-dir $(pwd)/full-context
339-
--offline
340-
--no-progress
341-
--remap 'https://docs.nextcloud.com/server/ file://$(pwd)/full-context/server/'
342-
--exclude 'mailto:'
343-
--exclude '(https?:/?/?)?$'
344-
--exclude-path '.*/404\.html'
345-
'full-context/server/${{ steps.branch.outputs.branch_name }}/**/*.html'
346-
347-
- name: Clean up validation context
348-
if: always()
349-
run: rm -rf full-context
340+
name: full-context
341+
path: full-context/
342+
retention-days: 1
350343

351344
# ========================================================================
352345
# UPLOAD STAGING ARTIFACTS
@@ -361,6 +354,50 @@ jobs:
361354
path: stage/
362355
retention-days: 1
363356

357+
# ============================================================================
358+
# LINK CHECK
359+
# ============================================================================
360+
# Runs in parallel with deploy. Downloads the full validation context
361+
# prepared by stage-and-check, strips canonical links, then runs lychee.
362+
# ============================================================================
363+
link-check:
364+
name: Check for broken links
365+
needs: stage-and-check
366+
runs-on: ubuntu-latest
367+
368+
steps:
369+
- name: Download full validation context
370+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
371+
with:
372+
name: full-context
373+
path: full-context/
374+
375+
- name: Strip canonical HEAD link from validation HTML
376+
run: |
377+
find "full-context/server/${{ needs.stage-and-check.outputs.branch_name }}" -name '*.html' -print0 | while IFS= read -r -d '' f; do
378+
perl -0pi -e 's{^\s*<link rel="canonical" href="https://docs\.nextcloud\.com/server/[^"]*" />\n}{}m' "$f"
379+
done
380+
381+
- name: Check for broken links with lychee
382+
uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0
383+
with:
384+
fail: true
385+
token: ${{ secrets.GITHUB_TOKEN }}
386+
jobSummary: true
387+
args: |
388+
--root-dir $(pwd)/full-context
389+
--offline
390+
--no-progress
391+
--remap 'https://docs.nextcloud.com/server/ file://$(pwd)/full-context/server/'
392+
--exclude 'go\.php'
393+
--exclude 'mailto:'
394+
--exclude-path '.*/404\.html'
395+
# Ignore version sidebar selector links
396+
--exclude '^file://.*/full-context/(latest|stable|[0-9]+)/(developer_manual|admin_manual|user_manual)/?$'
397+
'full-context/server/${{ needs.stage-and-check.outputs.branch_name }}/user_manual/en/**/*.html'
398+
'full-context/server/${{ needs.stage-and-check.outputs.branch_name }}/admin_manual/**/*.html'
399+
'full-context/server/${{ needs.stage-and-check.outputs.branch_name }}/developer_manual/**/*.html'
400+
364401
# ============================================================================
365402
# DEPLOY
366403
# ============================================================================
@@ -504,7 +541,7 @@ jobs:
504541
GH_TOKEN: ${{ secrets.COMMAND_BOT_PAT }}
505542

506543
summary:
507-
needs: [build-html, build-pdf, stage-and-check, deploy]
544+
needs: [build-html, build-pdf, stage-and-check, link-check, deploy]
508545
runs-on: ubuntu-latest-low
509546
if: always()
510547

@@ -518,10 +555,9 @@ jobs:
518555
run: |
519556
if ${{ github.event_name == 'pull_request' }}
520557
then
521-
echo "This workflow ran for a pull request. We need build-html, build-pdf and stage-and-check to succeed, but deploy will be skipped"
522-
if ${{ needs.build-html.result != 'success' || needs.build-pdf.result != 'success' || needs.stage-and-check.result != 'success' || needs.deploy.result != 'skipped' }}; then exit 1; fi
558+
echo "This workflow ran for a pull request. We need build-html, build-pdf, stage-and-check and link-check to succeed, but deploy will be skipped"
559+
if ${{ needs.build-html.result != 'success' || needs.build-pdf.result != 'success' || needs.stage-and-check.result != 'success' || needs.link-check.result != 'success' || needs.deploy.result != 'skipped' }}; then exit 1; fi
523560
else
524561
echo "This workflow ran for a push. We need all jobs to succeed, including deploy"
525-
if ${{ needs.build-html.result != 'success' || needs.build-pdf.result != 'success' || needs.stage-and-check.result != 'success' || needs.deploy.result != 'success' }}; then exit 1; fi
562+
if ${{ needs.build-html.result != 'success' || needs.build-pdf.result != 'success' || needs.stage-and-check.result != 'success' || needs.link-check.result != 'success' || needs.deploy.result != 'success' }}; then exit 1; fi
526563
fi
527-

0 commit comments

Comments
 (0)