nix-community.nixvim/.github/actions/build-docs/action.yml
Matt Sturgeon 40bf948e0e ci/docs: extract action & refactor workflow
Extract the "build" part of building & deploying the docs website into a
`build-docs` composite action.

Refactor the workflow to use a matrix job strategy; allowing each branch
to be built in parallel and in isolation.

In a subsequent job, we combine the builds into a single artifact.
2025-06-15 21:24:10 +00:00

78 lines
2.1 KiB
YAML

name: Build Documentation
description: >
Build Nixvim's documentation and upload an artifact.
Requires having nix installed and Nixvim checked out.
inputs:
sub-path:
description: Move the docs to this sub-directory path.
default: ""
base-href:
description: The base href to use when building the docs.
default: /nixvim/
versions:
description: JSON array describing Nixvim versions to be linked in the docs.
default: "[]"
artifact-name:
description: Artifact name. Set to "" to prevent uploading.
default: docs
retention-days:
description: Days after which artifact will expire.
default: "1"
outputs:
artifact-id:
description: The ID of the artifact that was uploaded.
value: ${{ steps.upload.outputs.artifact-id }}
runs:
using: "composite"
steps:
- name: Create temp directory
id: out-dir
shell: bash
run: |
dir=$(mktemp -d)
{
echo "dir=$dir"
echo "out=$dir/out"
} >> "$GITHUB_OUTPUT"
- name: nix-build
shell: bash
env:
out: ${{ steps.out-dir.outputs.out }}
subPath: ${{ inputs.sub-path }}
baseHref: ${{ inputs.base-href }}
versions: ${{ inputs.versions }}
run: |
nix-build \
--out-link "$out/$subPath" \
--argstr baseHref "$baseHref" \
--argstr versionsJson "$versions" \
--expr '
{
baseHref,
versionsJson,
system ? builtins.currentSystem,
}:
let
# Import flake using flake-compat
flake = import ./.;
inherit (flake.outputs.packages.${system}) docs;
in
docs.override {
inherit baseHref;
availableVersions = builtins.fromJSON versionsJson;
}
'
- name: Upload artifact
id: upload
if: inputs.artifact-name
uses: actions/upload-pages-artifact@v3
with:
path: ${{ steps.out-dir.outputs.out }}
name: ${{ inputs.artifact-name }}
retention-days: ${{ inputs.retention-days }}