feat: skip expensive build steps when source files unchanged (dorny/paths-filter)#14713
Draft
feat: skip expensive build steps when source files unchanged (dorny/paths-filter)#14713
Conversation
…ths-filter Agent-Logs-Url: https://github.com/nextcloud/documentation/sessions/ceff6c51-e231-4abd-95bd-52940cce5834 Co-authored-by: skjnldsv <14975046+skjnldsv@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add dorny/paths-filter to skip expensive steps in Sphinx build
feat: skip expensive build steps when source files unchanged (dorny/paths-filter)
May 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each matrix job in
sphinxbuild.ymlrebuilds unconditionally on every PR/push. This adds per-manual change detection so Python setup, pip install, build, and artifact upload are skipped entirely when nothing relevant changed.Changes
build-html+build-pdf: Adddorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36(v3.0.2) as step 2 in each matrix job; all expensive steps gated onsteps.filter.outputs.changed == 'true'${{ matrix.manual.directory }}/**,requirements.txt,.github/workflows/sphinxbuild.yml.devcontainer/DockerfileUpload static documentationcondition:${{ matrix.manual.publish && steps.filter.outputs.changed == 'true' }}link-check: Replace hardcoded lychee glob args with afind-based path list written to/tmp/lychee-paths.txt, passed via@/tmp/lychee-paths.txt. Avoids lychee errors when a manual directory was never staged because its build was skipped.The
on:trigger,prepare-pdf-image,stage-and-check,deploy, andsummaryjobs are untouched.☑️ Resolves
🖼️ Screenshots
No visual output changes.
✅ Checklist
codespellor similar and addressed any spelling issuesOriginal prompt
Goal
In
.github/workflows/sphinxbuild.yml, usedorny/paths-filterinside each matrix job to skip all expensive steps (Python setup, pip install, build, upload) when the relevant source files haven't changed. The workflow trigger should remain untouched (still runs on all PRs and pushes tomaster/stable*).Changes needed
1.
build-htmljobAdd
dorny/paths-filteras the second step (after checkout), filtering on:${{ matrix.manual.directory }}/**requirements.txt.github/workflows/sphinxbuild.ymlGate all subsequent steps (
Set up Python,Install pip dependencies,Build html documentation,Upload static documentation) onsteps.filter.outputs.changed == 'true'.The
Upload static documentationstep currently hasif: ${{ matrix.manual.publish }}— this should becomeif: matrix.manual.publish && steps.filter.outputs.changed == 'true'.2.
build-pdfjobSame pattern. Add
dorny/paths-filteras the second step, filtering on:${{ matrix.manual.directory }}/**requirements.txt.devcontainer/Dockerfile.github/workflows/sphinxbuild.ymlGate all subsequent steps on
steps.filter.outputs.changed == 'true'.3.
link-checkjobThe lychee args currently hardcode globs for all three manuals. If a manual was skipped (no artifact), its folder won't exist in
stage/and lychee may fail. Make each glob conditional on whether the directory actually exists, for example using a shellfindor[ -d ... ]check before the lychee step, and only pass globs for directories that exist.Specifically, add a step before lychee that builds the list of paths to check into an env var or file, then pass that to the lychee
args. Or use a simpler approach: usefindto discover all relevant*.htmlfiles and pass the list, skipping missing directories.4. Pin
dorny/paths-filterUse a pinned commit SHA for
dorny/paths-filter, similar to how all other actions in this file are pinned. Usev3— the SHA fordorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36is correct forv3.0.2.Constraints
on:trigger block.prepare-pdf-imagejob — it already has its own Dockerfile change detection.stage-and-check,deploy, orsummaryjobs.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: So, we build the documentation every time on PR.
For faster builds, is it possible to do some kind of hash or something and only compile if the content of the manual change ?
Assistant: Yes! GitHub Actions has a built-in, idiomatic solution for this:
paths/paths-ignorefilters on the workflow trigger. This is simpler and more reliable than computing hashes yourself.The approach:
pathsfilter on the triggerYou add a
pathsfilter to theon:block. GitHub will then only trigger the workflow when at least one of those matching files changed in the PR/push.What this gives you
user_manual/**.github/workflows/other.ymlrequirements.txt.devcontainer/DockerfileIf
sphinxbuild.ymljobs are set as required checks on branch protection, a skipped run won't satisfy the requirement by default. You have two options:summaryjob pattern you already have — make thesummaryjob the required check. When the workflow is skipped entirely, you can add a separate small "skip" workflow that usespaths-ignoreinversely and just posts a passing status. This is the ["always-passing required check" pattern](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/troubleshooting-required-status-checks#handling-skipped-...This pull request was created from Copilot chat.