mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-09 08:44:32 +02:00
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.
This commit is contained in:
parent
91ecff36b6
commit
40bf948e0e
2 changed files with 156 additions and 90 deletions
78
.github/actions/build-docs/action.yml
vendored
Normal file
78
.github/actions/build-docs/action.yml
vendored
Normal file
|
@ -0,0 +1,78 @@
|
|||
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 }}
|
Loading…
Add table
Add a link
Reference in a new issue