ci/website: simplify docs build

- Drop branch-specific composite action, target branches via flakeref
- Avoid flake-compat, using `nix build --impure` and `getEnv`
This commit is contained in:
Matt Sturgeon 2026-06-07 18:27:15 +01:00 committed by Gaétan Lepage
parent a1ef7c93db
commit 643284206b
3 changed files with 16 additions and 89 deletions

View file

@ -1,78 +0,0 @@
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@v5
with:
path: ${{ steps.out-dir.outputs.out }}
name: ${{ inputs.artifact-name }}
retention-days: ${{ inputs.retention-days }}

View file

@ -96,19 +96,23 @@ jobs:
name: nix-community
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ matrix.ref }}
# Uses the build-docs action from the checked-out nixvim branch
# Build the `docs` flake output from the corresponding branch
# Uses --impure to enable `getEnv`
- name: Build docs
uses: ./.github/actions/build-docs
env:
ref: ${{ matrix.ref }}
outLink: build/${{ matrix.sub-path }}
NIXVIM_DOCS_BASE_HREF: ${{ matrix.base-href }}
NIXVIM_DOCS_AVAILABLE_VERSIONS: ${{ needs.prepare.outputs.versions }}
run: |
nix build "github:$GITHUB_REPOSITORY/$ref#docs" --impure --out-link "$outLink"
- name: Upload artifact
uses: actions/upload-pages-artifact@v5
with:
artifact-name: ${{ matrix.name }}-docs
sub-path: ${{ matrix.sub-path }}
base-href: ${{ matrix.base-href }}
versions: ${{ needs.prepare.outputs.versions }}
path: build
name: ${{ matrix.name }}-docs
retention-days: 1
combine:
name: Combine builds

View file

@ -1,4 +1,5 @@
# NOTE: to use defaults from the environment, you must build with --impure
# This is used in CI to inject impure baseHref and availableVersions values
{
pkgs,
callPackage,