From 643284206b9fe4761fd1417025aebf6903b31fa5 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Sun, 7 Jun 2026 18:27:15 +0100 Subject: [PATCH] ci/website: simplify docs build - Drop branch-specific composite action, target branches via flakeref - Avoid flake-compat, using `nix build --impure` and `getEnv` --- .github/actions/build-docs/action.yml | 78 --------------------------- .github/workflows/website.yml | 26 +++++---- docs/mdbook/default.nix | 1 + 3 files changed, 16 insertions(+), 89 deletions(-) delete mode 100644 .github/actions/build-docs/action.yml diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml deleted file mode 100644 index 09435781..00000000 --- a/.github/actions/build-docs/action.yml +++ /dev/null @@ -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 }} diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index 02daaea3..2c717cb2 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -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 diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 5c3f57c6..0040796f 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -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,