feat(docs): use workflow for version docs generation

This commit is contained in:
xtheeq 2026-05-26 18:25:50 +05:30 committed by DreamMaoMao
parent e29cec64e4
commit 6238fab9e6
96 changed files with 50 additions and 6822 deletions

View file

@ -53,11 +53,11 @@ jobs:
python3 ./.github/scripts/generate-nix-options-docs.py \
/tmp/nixos-raw.md \
/tmp/hm-raw.md \
docs/nix-options.md
'docs/nix-options.md'
- name: Auto-commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "docs: auto-generate Nix module options"
file_pattern: 'docs/*-options.md'
file_pattern: 'docs/nix-options.md'
branch: ${{ github.head_ref }}

View file

@ -17,9 +17,11 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
token: ${{ github.token }}
- name: Fetch tags for versioned docs
run: git fetch origin --tags --depth=1
- name: Checkout website
uses: actions/checkout@v4
with:
@ -30,8 +32,31 @@ jobs:
- name: Sync docs
run: |
rm -rf website/apps/web/content/docs
cp -r docs website/apps/web/content/docs
TARGET=website/apps/web/content/docs
rm -rf "$TARGET"
mkdir -p "$TARGET"
# Copy current docs as "(git)"
cp -r docs "$TARGET/(git)"
# Generate versioned docs from last 2 semver tags
tags=$(git tag --sort=-v:refname | grep '^v\?[0-9]\+\.[0-9]\+\.[0-9]\+$' | head -2)
for tag in $tags; do
git worktree add /tmp/docs-"$tag" "$tag" || continue
if [ -d "/tmp/docs-$tag/docs" ]; then
name="v${tag#v}"
cp -r "/tmp/docs-$tag/docs" "$TARGET/$name"
fi
git worktree remove /tmp/docs-"$tag"
done
# Generate root version index
{
echo "(git)"
for tag in $tags; do
echo "v${tag#v}"
done
} | jq -Rn '[inputs | select(length > 0)] | {pages: .}' > "$TARGET/meta.json"
- name: Commit and push
working-directory: website