Skip to content

Workflow docs pages

github-actions[bot] edited this page Oct 25, 2026 · 2 revisions

docs-pages

What it does. Builds a static documentation site on every pull request and deploys it to GitHub Pages from the default branch only. Built for MkDocs (mkdocs build --strict after pip install -e ".[docs]"), but both commands are inputs, so anything that writes a directory of static files fits: Sphinx, mdBook, a script.

Why it exists. A strict build fails a pull request that breaks a link, so it is caught in review and not published as a 404. It was written from Hammunition's pages.yml; the project-specific parts (its site, its extra, its nav) stayed there.

Jobs and trust boundaries

Job Holds Notes
build contents: read and no token Runs your install and build commands. The artifact is uploaded exactly when the deploy will run
deploy pages: write, id-token: write Default branch only, never a pull request. Runs none of your commands. Fixed concurrency group pages: queues behind a running deployment and never cancels one

A minimal caller

on:
  push: { branches: [main] }
  pull_request:
  workflow_dispatch:

jobs:
  docs:
    uses: ChiefGyk3D/git-your-ship-together/.github/workflows/docs-pages.yml@<sha> # vX.Y.Z
    permissions:
      contents: read
      pages: write      # the deploy job only
      id-token: write   # the deploy job only: Pages verifies it

The owner sets one thing once: Settings, Pages, Build and deployment, Source: GitHub Actions. Until then deploy fails with a message that says so and names the URL; build is unaffected. deploy: false keeps a repository building only until the setting is made. The default egress list has not been measured against a caller, which is why the default policy is audit.

Inputs (9), read from docs-pages.yml:

Input Type Default Meaning
python-version string 3.11 Python used to build the site.
install-command string pip install -e ".[docs]" Shell run before the build, e.g. the project's docs extra.
build-command string mkdocs build --strict Shell that builds the site into site-dir. A non-zero exit fails the job, so a strict build (broken links, missing pages) fails the pull request.
site-dir string site Directory the build writes, relative to the repository root. It is uploaded as the Pages artifact.
deploy boolean true Upload and deploy on a run of the default branch. false only builds, which is what a repository wants while it tries the workflow before it has enabled Pages.
egress-policy string audit harden-runner egress policy for every job - audit logs outbound connections, block allows only allowed-endpoints.
allowed-endpoints string api.github.com:443 files.pythonhosted.org:443 github.com:443 pypi.org:443 harden-runner allow-list for block, space-separated host:port entries. Wildcards are not supported and a newline-separated list matches nothing. The runner's own infrastructure needs no entry; a build that fetches fonts or plugins needs its hosts in extra-allowed-endpoints.
extra-allowed-endpoints string empty Appended to allowed-endpoints, for hosts only this repository reaches. Same format.
timeout-minutes number 10 Per-job timeout.

What it refuses to do

It never deploys from a pull request, never lets your build command run beside the Pages write, and never publishes an empty or missing site directory.

Clone this wiki locally