Skip to content

About

Documentation verify/build/publishing workflows

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

ย 

History

215 Commits

Folders and files

Repository files navigation

๐Ÿ“š Documentation Workflows

Linux Foundation Source Code License OpenSSF Scorecard

Reusable workflows that check and publish Sphinx documentation through ReadTheDocs, for projects using either GitHub or Gerrit as the source of truth.

Reusable workflows

Workflow Purpose Trigger style
.github/workflows/docs-build.yaml Audit, build and publish documentation Patchset, pull request or merge
.github/workflows/docs-audit.yaml Configuration policy audit alone Any

One workflow, two lanes

docs-build.yaml takes a mode input rather than splitting into two files. The verify lane audits the configuration, builds the documentation locally and probes ReadTheDocs without changing anything. The merge lane audits, then publishes.

Until now the lanes lived in two workflows that shared most of their body. They drifted, and in August 2026 the drift broke every documentation merge across ONAP: the verify copy had moved off an end-of-life Python while the merge copy had not. A single file removes that class of failure.

Jobs in { } run in parallel; -> denotes sequence:

verify:  audit -> { docs | linkcheck | readthedocs }
merge:   audit -> readthedocs

The audit resolves the documentation Python version and the location of the tox file, then passes both to the jobs that follow. Both builds then use the same interpreter, and the build runs from wherever the project keeps its documentation environments: docs/tox.ini where one exists, otherwise tox.ini at the root.

Documentation Python and tox Python

The documentation Python is the one the audit resolves: the tox docs environment's basepython where the project pins one, otherwise build.tools.python from .readthedocs.yaml, otherwise Python 3.13. tox-run-action runs tox itself on the last Python it sets up and needs Python 3.11 or newer for that:

  • 3.11 or newer: the jobs set up that Python alone. tox and the documentation both run on it.
  • Older than 3.11: the jobs set up the documentation Python, then Python 3.13. tox runs on 3.13; the documentation still builds on the documentation Python.

When the documentation Python is older than 3.11, the build and link check jobs also set TOX_OVERRIDE=testenv.default_base_python=pythonX.Y, so a tox environment that pins no basepython still builds on the documentation Python rather than on tox's, as Read the Docs would. A basepython the project pins wins over that default. The audit job then warns, and notes in its job summary, that tox runs on Python 3.13, that the documentation still builds on the declared Python, and when the declared Python has reached end of life. Move the documentation to a supported Python to clear the warning.

The python_versions output lists the versions set up, one per line.

Discovery gates the work

The audit also reports whether the repository ships documentation at all, and every job after it gates on that finding:

Job Runs when
docs the audit found a tox file
linkcheck the audit found a tox file
readthedocs the audit found a .readthedocs.yaml

The signals differ because the tools differ. The build and link check run tox; ReadTheDocs builds from .readthedocs.yaml held in the repository. A project may carry one without the other.

This matters most on a merge. The ReadTheDocs job creates the project when it finds none, so running it against a repository with no documentation registers a project that can never build. A repository with no .readthedocs.yaml instead gets a note in the job summary naming which jobs skip and why.

Usage

Call from a thin caller workflow. See examples/docs-build/ for a GitHub-native caller, a Gerrit verify wrapper and a Gerrit merge wrapper.

jobs:
  docs:
    permissions:
      contents: read
    uses: lfreleng-actions/docs-workflows/.github/workflows/docs-build.yaml@<sha>
    with:
      mode: ${{ github.event_name == 'push' && 'merge' || 'verify' }}
    secrets:
      RTD_TOKEN: ${{ secrets.RTD_TOKEN }}

Gerrit projects

The workflows are Gerrit-aware for checkout: pass gerrit_refspec, gerrit_project, gerrit_branch and gerrit_url and every checkout-bearing job fetches the unmerged change rather than the branch.

Voting stays in the caller. The reusable workflows never receive a Gerrit SSH key; the wrapper clears the vote, calls the workflow and votes the conclusion. This matches the pattern the sibling *-workflows repositories follow.

examples/docs-build/gerrit.yaml shows the verify wrapper and gerrit-merge.yaml the merge wrapper. Copy them into .github/workflows/ with filenames gerrit_to_platform can discover: one containing both gerrit and verify, the other both gerrit and merge.

Link checking

linkcheck_advisory defaults to true, so a failing link check reports without blocking.

External sites increasingly refuse automated requests, classing them as unwanted crawler traffic. A link check that fails the build on an unreachable URL reports another site's bot policy as a fault in the change under review, and the author can do nothing about it. In a sample of 500 production runs, broken third-party links accounted for the largest single group of documentation failures.

Set linkcheck_advisory: false to make link failures block, or linkcheck_enabled: false to skip the check.

The audit reports separately when a project sets -W on its linkcheck tox environment, which turns the same third-party unreliability into a hard failure inside the project's own configuration.

Runner parity

The documentation builds twice: in the docs and linkcheck jobs with tox, and on Read the Docs. When the two environments differ, one can fail while the other passes, so the workflow matches the GitHub build to the Read the Docs one.

Build runner. The audit maps the project's build.os to the matching GitHub runner label, and the docs and linkcheck jobs run on it. The label comes from a file in the repository under test, so the jobs accept no labels beyond ubuntu-22.04, ubuntu-24.04 and ubuntu-26.04. When build.os has no matching runner, or names anything else, the jobs fall back to ubuntu-24.04 and the docs job warns. Its job summary reports the runner OS, the label the audit asked for and the apt packages installed.

Audit runner. The audit job runs on ubuntu-24.04 rather than ubuntu-latest, in both workflows. The audit compares its own OS with build.os, and GitHub assigns ubuntu-latest to 24.04 or 26.04 at random during its migration, so on that label the runner-os-mismatch warning would come and go between runs.

Apt packages. Both build jobs install the project's build.apt_packages before tox runs, as Read the Docs does. The names reach a command run as root, so the jobs check them again after the audit has.

Not reproduced. Read the Docs build.jobs and build.commands do not run in the GitHub build. The audit warns when a project declares them.

Runner hardening

Every job loads the organisation egress allow-list and runs harden-runner in block mode, except the link-check job.

A link check contacts whichever hosts the documentation links to, which no allow-list can list ahead of time, so that job runs in audit mode. Blocking there would defeat the check rather than secure it.

harden_runner_egress: audit relaxes the remaining jobs when a project needs to observe its egress before committing to a block list.

A project whose build needs endpoints beyond the organisation baseline names its own list in harden_runner_supplemental_allowlist, using the same coordinate grammar as harden_runner_allowlist. The jobs merge it with the baseline, so the extra endpoints reach that project alone rather than every caller:

with:
  harden_runner_supplemental_allowlist: 'onap//.github/harden-runner/onap/allow_list.txt@<commit sha>'

Pin the list to a commit. Naming a list makes the jobs depend on it: if it cannot load, the job fails at once rather than at the first blocked connection. A supplemental list extends the baseline, so setting one with an empty harden_runner_allowlist fails the run.

A project may instead let its list follow the default branch of the repository holding it, so a newly merged endpoint reaches every job at once with no pin to bump. Omit the @ref and opt in with harden_runner_supplemental_unpinned:

with:
  harden_runner_supplemental_allowlist: 'onap//.github/harden-runner/onap/allow_list.txt'
  harden_runner_supplemental_unpinned: true

The action refuses an unpinned list unless the repository holding it belongs to the calling workflow's organisation. That rule keeps trust within one organisation: whoever can change onap/.github can already change the workflows ONAP projects run, so following its default branch grants them nothing new. A list from another organisation must still carry a pin. Without the opt-in, the jobs refuse a list that lacks @ref.

docs-build.yaml fails the run when a caller sets the opt-in but names no supplemental list. docs-audit.yaml has no validation job, so a standalone audit given the opt-in without a list ignores it and runs on the baseline alone.

When a build breaks on a newly blocked endpoint and cannot wait for a list change to merge, name the endpoint inline in harden_runner_extra_endpoints, as host[:port] tokens separated by spaces or newlines. The jobs merge them into the allow-list for that caller alone:

with:
  harden_runner_extra_endpoints: 'registry.nordix.org:443'

Treat this as a short-term fix. Endpoints written inline live in each caller's workflow, where no other project can reuse them, so move them into the project's supplemental list and drop the input once that change lands. An unpinned supplemental list leaves no pin in the caller's history; the block-action step records the list it resolved in its supplemental_source and supplemental_sha outputs, which serve as the audit trail for what each run allowed.

Inputs

docs-build.yaml requires mode alone. Every other input carries a default that suits a project following the Linux Foundation documentation layout.

Group Inputs
Lane mode
Checkout repository, ref
Gerrit gerrit_refspec, gerrit_project, gerrit_branch, gerrit_url
Layout path_prefix, tox_dir, docs_tox_env, linkcheck_tox_env
Build docs_enabled, linkcheck_enabled, linkcheck_advisory
Audit audit_enabled, audit_required_files, audit_forbidden_files, audit_build_os, audit_python_version, audit_eol_behaviour, audit_linkcheck_policy, audit_fail_on_warning
ReadTheDocs rtd_enabled, rtd_project, rtd_parent_project, rtd_parent_suffix, rtd_project_overrides, rtd_default_version, rtd_default_branch, lftools_version
Hardening harden_runner_egress, harden_runner_allowlist, harden_runner_supplemental_allowlist, harden_runner_supplemental_unpinned, harden_runner_extra_endpoints
Timeouts docs_timeout_minutes, rtd_timeout_minutes

Secrets: RTD_TOKEN, required when rtd_enabled stays true.

lftools_version names the lftools-uv release the ReadTheDocs job runs, with every dependency pinned to an exact version. It defaults to 0.11.0, the oldest release rtd-build-action accepts; an older value fails the ReadTheDocs step before any ReadTheDocs API call.

Outputs: docs_python, python_versions, audit_passed, runner, apt_packages, documentation_url, cancelled_builds.

ReadTheDocs naming

The workflow supplies gerrit_project and gerrit_url to rtd-build-action, which derives the ReadTheDocs slugs from them. A project needs no naming configuration in the common case.

Set rtd_project or rtd_parent_project to bypass derivation, or rtd_project_overrides for a project following no derivable rule.

Composition

The workflows carry no shell beyond input validation, reporting and the Read the Docs apt install. The rest of the work lives in actions, so tests cover it without a workflow run:

Action Role
rtd-config-audit-action Parses .readthedocs.yaml, resolves the documentation Python version
rtd-build-action Drives the ReadTheDocs API for both lanes
tox-run-action Runs the documentation and link-check environments
checkout-gerrit-change-action Fetches an unmerged Gerrit change
harden-runner-block-action Loads the organisation egress allow-list

Testing

.github/workflows/testing.yaml exercises both workflows against a real documentation project by self-repository path (uses: $/...), which resolves this repository at the commit already running, so a pull request validates the branch under review.

Three further legs build the fixtures under tests/fixtures/docs-python, whose tox environments fail unless they run on the Python the fixture declares: 3.11 pinned by basepython, 3.11 declared in .readthedocs.yaml alone, and 3.12.

The uv-isolation job plants bait interpreters on PATH and in the variables uv reads (UV_PYTHON, UV_PYTHON_SEARCH_PATH, VIRTUAL_ENV, CONDA_PREFIX, UV_INTERNAL__PARENT_INTERPRETER), and a bait uv in the directory UV_PYTHON_INSTALL_DIR names, through GITHUB_ENV and GITHUB_PATH. It proves each bait starts, then fails if the guarded setup-uv step the ReadTheDocs job uses starts any of them.

The ReadTheDocs legs stay disabled there. Reaching the API needs a token a fork may not hold, and the merge lane would create and build real ReadTheDocs projects, which a test run has no business doing. rtd-build-action covers that behaviour with its own suite against an in-memory double.

About

Documentation verify/build/publishing workflows

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors