nix-community.nixvim/.github/workflows/website.yml
Matt Sturgeon b4750c4696 ci/docs: fix base-href in matrix
For some reason, when updating `base-href` using `+=`, yq updates _all_
entries matching the LHS selection. This means that all non-main
branches get `"base-href": "/nixvim/24.11/"` in the job matrix.

This gets passed in as an overridden attr when building the docs, and is
used to determine which list item represents the currently-being-built
docs; therefore both 25.05 and 24.11 think they are 24.11...

For some reason, while `+=` does this, `=` does not. So switched to
using that.
2025-06-17 19:12:50 +00:00

155 lines
3.8 KiB
YAML

name: Documentation
on:
push:
branches:
- main
# Allow running manually
workflow_dispatch:
# Allow one concurrent deployment
concurrency:
group: docs-website
cancel-in-progress: true
jobs:
prepare:
name: Version info
runs-on: ubuntu-24.04-arm
outputs:
matrix: ${{ steps.matrix.outputs.result }}
versions: ${{ steps.versions.outputs.result }}
steps:
- name: Checkout version-info
uses: actions/checkout@v4
with:
sparse-checkout: version-info.toml
sparse-checkout-cone-mode: false
- name: Produce build matrix
id: matrix
uses: mikefarah/yq@master
with:
cmd: |
yq --no-colors --output-format=json '
[
.versions
| to_entries
| reverse
| .[]
| {
"ref": .value.branch,
"name": .key,
"base-href": "/nixvim/"
}
| select(.ref != "main").sub-path = .name
| select(.ref != "main").base-href = "\(.base-href)\(.name)/"
]
' version-info.toml
- name: Produce "other versions" array
id: versions
uses: mikefarah/yq@master
with:
cmd: |
yq --no-colors --output-format=json '
[
.versions
| to_entries
| reverse
| .[]
| {
"branch": .value.branch,
"nixpkgsBranch": .value.channel,
"baseHref": "/nixvim/\(.key)/"
}
| select(.branch == "main").baseHref = "/nixvim/"
]
' version-info.toml
# TODO: add channel status
build:
name: Build ${{ matrix.name }}
runs-on: ubuntu-latest
needs: prepare
strategy:
fail-fast: true
matrix:
include: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- name: Install nix
uses: cachix/install-nix-action@v31
- name: Configure cachix
uses: cachix/cachix-action@v16
with:
name: nix-community
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}
# Uses the build-docs action from the checked-out nixvim branch
- name: Build docs
uses: ./.github/actions/build-docs
with:
artifact-name: ${{ matrix.name }}-docs
sub-path: ${{ matrix.sub-path }}
base-href: ${{ matrix.base-href }}
versions: ${{ needs.prepare.outputs.versions }}
combine:
name: Combine builds
runs-on: ubuntu-24.04-arm
needs: build
env:
in: artifacts
out: combined
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ${{ env.in }}
pattern: "*-docs"
merge-multiple: false
- name: Extract archives
run: |
mkdir -p "$out"
find "$in" -name artifact.tar \
| parallel tar \
--verbose \
--extract \
--file {} \
--directory "$out"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ${{ env.out }}
deploy:
name: Deploy
runs-on: ubuntu-24.04-arm
needs: combine
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4