From 98f1271b01b160fd1ac9eb2320280ffd8bf4945d Mon Sep 17 00:00:00 2001 From: Hakula Chen Date: Sun, 6 Dec 2026 17:35:29 +0800 Subject: [PATCH] feat(docs-site): add reusable docs workflows and mkDocsShell Add reusable docs-site infrastructure for documentation sites built with Node and pnpm and deployed to Cloudflare Workers. - Add `dk.mkDocsShell` in `nix/lib.nix` providing `nodeToolchain`, `lychee`, and `playwright-driver.browsers` with `PLAYWRIGHT_BROWSERS_PATH` exported in both `env` and `shellHook`. - Add `dev-shell` input support to the `workers` action and `scripts/workers.nu` so preview and production deploys can enter a non-default flake dev shell. - Add `.github/workflows/docs.yml` for formatting, typecheck, lint, build, optional lychee link checks, optional E2E tests, PR preview deploys with sticky comments, and default-branch production deploys. - Add `.github/workflows/docs-cleanup.yml` to remove PR preview deployments on `pull_request_target: closed`. - Group Astro and Starlight minor and major npm updates in `default.json` with automerge disabled. - Document the contract in `docs/docs-site.md` and link it from `AGENTS.md`, `README.md`, and `docs/ci.md`. --- .github/actions/workers/action.yml | 4 + .github/workflows/docs-cleanup.yml | 80 +++++++++ .github/workflows/docs.yml | 267 +++++++++++++++++++++++++++++ AGENTS.md | 1 + README.md | 1 + default.json | 14 ++ docs/ci.md | 18 +- docs/docs-site.md | 132 ++++++++++++++ nix/lib.nix | 25 +++ scripts/workers.nu | 8 +- 10 files changed, 541 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/docs-cleanup.yml create mode 100644 .github/workflows/docs.yml create mode 100644 docs/docs-site.md diff --git a/.github/actions/workers/action.yml b/.github/actions/workers/action.yml index a6097a2..057e7ca 100644 --- a/.github/actions/workers/action.yml +++ b/.github/actions/workers/action.yml @@ -5,6 +5,9 @@ inputs: directory: description: Directory containing the Worker's package and Wrangler configuration default: '.' + dev-shell: + description: Flake dev shell attribute providing Node and pnpm + default: '' wrangler-environment: description: Wrangler environment for a branch deployment default: '' @@ -32,6 +35,7 @@ runs: env: GH_TOKEN: ${{ github.token }} WORKER_DIRECTORY: ${{ inputs.directory }} + WORKER_DEV_SHELL: ${{ inputs.dev-shell }} WRANGLER_ENVIRONMENT: ${{ inputs.wrangler-environment }} D1_DATABASE: ${{ inputs.d1-database }} run: | diff --git a/.github/workflows/docs-cleanup.yml b/.github/workflows/docs-cleanup.yml new file mode 100644 index 0000000..0636b1a --- /dev/null +++ b/.github/workflows/docs-cleanup.yml @@ -0,0 +1,80 @@ +name: Docs Preview Cleanup + +on: + workflow_call: + inputs: + directory: + description: Directory containing the docs site package + type: string + default: '.' + shell: + description: Flake dev shell attribute providing the docs toolchain + type: string + default: 'default' + sparse-checkout: + description: Non-cone sparse-checkout patterns passed to actions/checkout + type: string + default: '' + submodules: + description: Check out submodules + type: boolean + default: false + secrets: + CLOUDFLARE_API_TOKEN: + description: Cloudflare API token for preview cleanup + required: true + CLOUDFLARE_ACCOUNT_ID: + description: Cloudflare account that owns the Worker if Wrangler omits account_id + required: false + +permissions: + contents: read + pull-requests: read + +jobs: + cleanup: + name: Delete Preview + if: >- + github.event_name == 'pull_request_target' && + github.event.action == 'closed' && + github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.user.login != 'dependabot[bot]' + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + pull-requests: read + concurrency: + group: preview-${{ github.event.pull_request.number }} + queue: max + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + sparse-checkout: ${{ inputs.sparse-checkout }} + sparse-checkout-cone-mode: ${{ inputs.sparse-checkout == '' }} + submodules: ${{ inputs.submodules }} + + - name: Set up Nix + uses: $/.github/actions/setup-nix + + - name: Install dependencies + env: + DOCS_DIRECTORY: ${{ inputs.directory }} + DOCS_SHELL: ${{ inputs.shell }} + run: | + nix develop ".#$DOCS_SHELL" \ + --print-build-logs \ + -c pnpm --dir "$DOCS_DIRECTORY" install --frozen-lockfile + + - name: Delete preview + uses: $/.github/actions/workers + with: + directory: ${{ inputs.directory }} + dev-shell: ${{ inputs.shell }} + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..ac542e0 --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,267 @@ +name: Docs + +on: + workflow_call: + inputs: + directory: + description: Directory containing the docs site package + type: string + default: '.' + shell: + description: Flake dev shell attribute providing the docs toolchain + type: string + default: 'default' + lychee: + description: Check internal links in the built dist output with lychee + type: boolean + default: true + e2e: + description: Run Playwright end-to-end tests + type: boolean + default: false + deploy: + description: Upload dist and deploy pull request previews and default-branch builds to Workers + type: boolean + default: false + wrangler-environment: + description: Wrangler environment for production deployments + type: string + default: '' + sparse-checkout: + description: Non-cone sparse-checkout patterns passed to actions/checkout + type: string + default: '' + submodules: + description: Check out submodules + type: boolean + default: false + secrets: + CACHIX_AUTH_TOKEN: + description: Upload token for the `hakula` Cachix cache + CLOUDFLARE_API_TOKEN: + description: Cloudflare API token for preview and production deployments + required: false + CLOUDFLARE_ACCOUNT_ID: + description: Cloudflare account that owns the Worker if Wrangler omits account_id + required: false + +permissions: + contents: read + +jobs: + build: + name: Build & Check + runs-on: ubuntu-latest + env: + DOCS_DIRECTORY: ${{ inputs.directory }} + DOCS_SHELL: ${{ inputs.shell }} + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + sparse-checkout: ${{ inputs.sparse-checkout }} + sparse-checkout-cone-mode: ${{ inputs.sparse-checkout == '' }} + submodules: ${{ inputs.submodules }} + + - name: Set up Nix + uses: $/.github/actions/setup-nix + with: + cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Install dependencies + run: | + nix develop ".#$DOCS_SHELL" \ + --print-build-logs \ + -c pnpm --dir "$DOCS_DIRECTORY" install --frozen-lockfile + + - name: Check formatting + run: nix develop ".#$DOCS_SHELL" -c pnpm --dir "$DOCS_DIRECTORY" run format:check + + - name: Typecheck + run: nix develop ".#$DOCS_SHELL" -c pnpm --dir "$DOCS_DIRECTORY" run check + + - name: Lint + run: nix develop ".#$DOCS_SHELL" -c pnpm --dir "$DOCS_DIRECTORY" run lint + + - name: Build + run: nix develop ".#$DOCS_SHELL" -c pnpm --dir "$DOCS_DIRECTORY" run build + + - name: Check links + if: ${{ inputs.lychee }} + run: | + nix develop ".#$DOCS_SHELL" -c sh -s -- "$DOCS_DIRECTORY" <<'EOF' + set -eu + cd "$1" + exec lychee \ + --offline \ + --root-dir "$PWD/dist" \ + dist + EOF + + - name: Run E2E tests + if: ${{ inputs.e2e }} + run: nix develop ".#$DOCS_SHELL" -c pnpm --dir "$DOCS_DIRECTORY" run test:e2e + + - name: Upload site artifact + if: ${{ inputs.deploy }} + uses: actions/upload-artifact@v7 + with: + name: docs-dist + path: ${{ inputs.directory }}/dist + if-no-files-found: error + + deploy-preview: + name: Deploy Preview + needs: [build] + if: >- + inputs.deploy && + github.event_name == 'pull_request' && + github.event.pull_request.head.repo.full_name == github.repository && + github.event.pull_request.user.login != 'dependabot[bot]' + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + pull-requests: write + concurrency: + group: preview-${{ github.event.pull_request.number }} + queue: max + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + sparse-checkout: ${{ inputs.sparse-checkout }} + sparse-checkout-cone-mode: ${{ inputs.sparse-checkout == '' }} + submodules: ${{ inputs.submodules }} + + - name: Set up Nix + uses: $/.github/actions/setup-nix + with: + cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Install dependencies + env: + DOCS_DIRECTORY: ${{ inputs.directory }} + DOCS_SHELL: ${{ inputs.shell }} + run: | + nix develop ".#$DOCS_SHELL" \ + --print-build-logs \ + -c pnpm --dir "$DOCS_DIRECTORY" install --frozen-lockfile + + - name: Download site artifact + uses: actions/download-artifact@v8 + with: + name: docs-dist + path: ${{ inputs.directory }}/dist + + - name: Deploy preview + id: workers + uses: $/.github/actions/workers + with: + directory: ${{ inputs.directory }} + dev-shell: ${{ inputs.shell }} + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + - name: Comment preview URL + if: ${{ steps.workers.outputs.applied == 'true' }} + uses: actions/github-script@v9 + env: + PREVIEW_URL: ${{ steps.workers.outputs.preview-url }} + DEPLOYMENT_URL: ${{ steps.workers.outputs.deployment-url }} + with: + script: | + const marker = ''; + const body = [ + marker, + `Preview: ${process.env.PREVIEW_URL}`, + `Deployment: ${process.env.DEPLOYMENT_URL}`, + ].join('\n'); + + const comments = await github.paginate(github.rest.issues.listComments, { + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + per_page: 100, + }); + const existing = comments.find( + (comment) => + comment.user?.login === 'github-actions[bot]' && comment.body?.includes(marker), + ); + + if (existing) { + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existing.id, + body, + }); + } else { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body, + }); + } + + deploy-production: + name: Deploy Production + needs: [build] + if: >- + inputs.deploy && + (github.event_name == 'push' || github.event_name == 'workflow_dispatch') && + github.ref == format('refs/heads/{0}', github.event.repository.default_branch) + runs-on: ubuntu-latest + timeout-minutes: 30 + permissions: + contents: read + concurrency: + group: docs-${{ inputs.wrangler-environment || 'production' }} + queue: max + + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + ref: ${{ github.sha }} + persist-credentials: false + sparse-checkout: ${{ inputs.sparse-checkout }} + sparse-checkout-cone-mode: ${{ inputs.sparse-checkout == '' }} + submodules: ${{ inputs.submodules }} + + - name: Set up Nix + uses: $/.github/actions/setup-nix + with: + cachix_auth_token: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Install dependencies + env: + DOCS_DIRECTORY: ${{ inputs.directory }} + DOCS_SHELL: ${{ inputs.shell }} + run: | + nix develop ".#$DOCS_SHELL" \ + --print-build-logs \ + -c pnpm --dir "$DOCS_DIRECTORY" install --frozen-lockfile + + - name: Download site artifact + uses: actions/download-artifact@v8 + with: + name: docs-dist + path: ${{ inputs.directory }}/dist + + - name: Deploy production + uses: $/.github/actions/workers + with: + directory: ${{ inputs.directory }} + dev-shell: ${{ inputs.shell }} + wrangler-environment: ${{ inputs.wrangler-environment }} + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} diff --git a/AGENTS.md b/AGENTS.md index 8d8641b..24e7c13 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,6 +9,7 @@ | Nushell application builders, `dk.nushell`, or skill helpers | [Nushell tooling](docs/nushell.md) | | `nu-test`, `nu-check`, or `nuTests` | [Nushell test runner](docs/nu-test.md) | | Nix or language CI, `ci-result`, or Workers deployment | [CI workflow and gate](docs/ci.md) | +| `mkDocsShell`, `docs.yml`, or `docs-cleanup.yml` | [Docs site](docs/docs-site.md) | | An action, a reusable workflow, or `cliff.toml` | [Releasing](docs/releasing.md) | | A devkit release or versioning decision | [Releasing devkit](RELEASING.md) | | The Renovate preset | [Renovate preset](docs/renovate.md) | diff --git a/README.md b/README.md index 8dfbd58..7abc9ed 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ devkit provides shared development tools for Hakula's repositories. | [Nushell tooling](docs/nushell.md) | Application and skill packaging | | [Nushell test runner](docs/nu-test.md) | Tests and script checks | | [CI workflow and gate](docs/ci.md) | CI checks and Workers deployment | +| [Docs site](docs/docs-site.md) | Docs shell, checks, and deployment | | [Releasing](docs/releasing.md) | Release a consumer project | | [Releasing devkit](RELEASING.md) | Version policy and rollback | | [Renovate preset](docs/renovate.md) | Dependency updates and automerge | diff --git a/default.json b/default.json index 6f1e5cc..5a0e2f1 100644 --- a/default.json +++ b/default.json @@ -68,6 +68,20 @@ "groupName": "Node dependencies", "automerge": true }, + { + "matchManagers": ["npm"], + "matchPackageNames": ["astro", "@astrojs/*", "starlight-*"], + "matchUpdateTypes": ["minor"], + "groupName": "Astro and Starlight", + "automerge": false + }, + { + "matchManagers": ["npm"], + "matchPackageNames": ["astro", "@astrojs/*", "starlight-*"], + "matchUpdateTypes": ["major"], + "groupName": "Astro and Starlight (major)", + "automerge": false + }, { "description": "Hold TypeScript below v7 until typescript-eslint supports it.", "matchDatasources": ["npm"], diff --git a/docs/ci.md b/docs/ci.md index b15a552..e8bb2ec 100644 --- a/docs/ci.md +++ b/docs/ci.md @@ -48,14 +48,16 @@ When adding checks, keep both of these settings on the gate required by the [bra ## Configure reusable workflows -| Job | What belongs here | Caller configuration | -| ---------------------------------------------------- | --------------------------------------------------- | ---------------------------------------------------------------------------------- | -| [Nix](../.github/workflows/nix.yml) | Flake checks and shared hooks | Expose packages under `checks` and include `preCommit` in the default dev shell | -| [Python](../.github/workflows/python.yml) | Python tests and coverage | Configure pytest in `pyproject.toml` | -| [Node](../.github/workflows/node.yml) | Node tests and coverage | Define the package's `test` script | -| [Rust](../.github/workflows/rust.yml) | Cargo tests, coverage, and optional MSRV checks | Set `msrv: true` for the `msrv` shell or `all_features: true` to test all features | -| [Project job](#add-project-jobs) | Project builds, packaging, or native Windows checks | Use the project toolchain and upload artifacts a later job consumes | -| [CI Result](../.github/actions/ci-result/action.yml) | One required status for all check jobs | Keep the job name `CI Result` and grant `actions: read` | +| Job | What belongs here | Caller configuration | +| ----------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------------------------------------------------ | +| [Nix](../.github/workflows/nix.yml) | Flake checks and shared hooks | Expose packages under `checks` and include `preCommit` in the default dev shell | +| [Python](../.github/workflows/python.yml) | Python tests and coverage | Configure pytest in `pyproject.toml` | +| [Node](../.github/workflows/node.yml) | Node tests and coverage | Define the package's `test` script | +| [Rust](../.github/workflows/rust.yml) | Cargo tests, coverage, and optional MSRV checks | Set `msrv: true` for the `msrv` shell or `all_features: true` to test all features | +| [Docs](../.github/workflows/docs.yml) | Docs site checks, links, E2E, and Workers deploy | Define docs scripts and grant `pull-requests: write` ([Docs site](docs-site.md)) | +| [Docs cleanup](../.github/workflows/docs-cleanup.yml) | Delete pull request previews on close | Call on `pull_request_target: closed` ([Docs site](docs-site.md#clean-up-pull-request-previews)) | +| [Project job](#add-project-jobs) | Project builds, packaging, or native Windows checks | Use the project toolchain and upload artifacts a later job consumes | +| [CI Result](../.github/actions/ci-result/action.yml) | One required status for all check jobs | Keep the job name `CI Result` and grant `actions: read` | ### Choose platforms diff --git a/docs/docs-site.md b/docs/docs-site.md new file mode 100644 index 0000000..e82d22d --- /dev/null +++ b/docs/docs-site.md @@ -0,0 +1,132 @@ +# Docs site + +devkit provides a flake dev shell, reusable GitHub Actions workflows, and Renovate rules for documentation sites deployed to Cloudflare Workers. + +## Set up the dev shell + +Use `dk.mkDocsShell` from [`nix/lib.nix`](../nix/lib.nix) to get Node 26 and pnpm 12 (`dk.nodeToolchain`), `lychee`, and `playwright-driver.browsers` with `PLAYWRIGHT_BROWSERS_PATH` set to `${pkgs.playwright-driver.browsers}`. Pass `name` (default `"docs-website"`) or `extraPackages` (default `[ ]`) to rename the shell or add packages. + +In a repository that keeps a docs site alongside other code, expose a dedicated shell and pass its attribute name as `shell` to the workflows. + +```nix +devShells.docs = dk.mkDocsShell { }; +``` + +In a standalone docs repository, expose `dk.mkDocsShell { }` as `devShells.default` directly or compose it with [`preCommit`](hooks.md#set-up-the-dev-shell) via `inputsFrom` so callers can omit the `shell` input. + +```nix +devShells.default = pkgs.mkShell { + inputsFrom = [ + preCommit + (dk.mkDocsShell { }) + ]; +}; +``` + +## Check and deploy a docs site + +The [`docs.yml`](../.github/workflows/docs.yml) reusable workflow checks a docs package and optionally deploys pull request previews and default-branch builds to Cloudflare Workers. + +Define these scripts in the docs site's `package.json`. + +- `format:check`, `check`, `lint`, and `build` (writing static files to `dist`) +- `test:e2e` when `e2e: true` +- `deploy` when `deploy: true` (invoked by the [`workers` action](../.github/actions/workers/action.yml)) + +Call `docs.yml` from a workflow in the consumer repository. Omit workflow-level `cancel-in-progress: true` when `deploy: true` so a running preview or production deployment can finish cleanly. + +```yaml +# .github/workflows/docs.yml +name: Docs + +on: + push: + branches: [main] + pull_request: + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + docs: + uses: hakulab/devkit/.github/workflows/docs.yml@v3 + with: + directory: docs + shell: docs + e2e: true + deploy: true + secrets: + CACHIX_AUTH_TOKEN: ${{ secrets.CACHIX_AUTH_TOKEN }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} +``` + +Grant `contents: read` and `pull-requests: write` on the calling workflow or job even when `deploy: false`, because GitHub validates reusable workflow job permissions statically. + +### Workflow jobs + +- **Build & Check** (`build`) runs `pnpm install --frozen-lockfile`, `format:check`, `check`, `lint`, and `build`. When `lychee` is enabled, it runs `lychee --offline --root-dir "$PWD/dist" dist` in `directory`, respecting any `lychee.toml` there. When `e2e` is enabled, it runs `pnpm run test:e2e`. When `deploy` is enabled, it uploads `/dist` as the `docs-dist` artifact. +- **Deploy Preview** (`deploy-preview`) runs after `build` when `deploy: true` on same-repo, non-Dependabot `pull_request` events, queued per PR in `preview-` (`queue: max`). It downloads `docs-dist`, runs the [`workers` action](../.github/actions/workers/action.yml) with `directory` and `dev-shell`, and creates or updates a sticky pull request comment (``) when `applied == 'true'`. +- **Deploy Production** (`deploy-production`) runs after `build` when `deploy: true` on default-branch `push` or `workflow_dispatch` events, queued in `docs-` (`queue: max`). It downloads `docs-dist` and deploys through the `workers` action. + +### Inputs and secrets + +| Input | Type | Default | Purpose | +| ---------------------- | ------- | ----------- | ------------------------------------------------------------------------- | +| `directory` | string | `'.'` | Directory containing the docs site package | +| `shell` | string | `'default'` | Flake dev shell attribute providing the docs toolchain | +| `lychee` | boolean | `true` | Check internal links in the built `dist` output with lychee | +| `e2e` | boolean | `false` | Run Playwright end-to-end tests (`pnpm run test:e2e`) | +| `deploy` | boolean | `false` | Upload `dist` and deploy PR previews and default-branch builds to Workers | +| `wrangler-environment` | string | `''` | Wrangler environment for production deployments | +| `sparse-checkout` | string | `''` | Non-cone sparse-checkout patterns passed to `actions/checkout` | +| `submodules` | boolean | `false` | Check out submodules | + +| Secret | Required | Purpose | +| ----------------------- | ------------------- | ---------------------------------------------------------------------- | +| `CACHIX_AUTH_TOKEN` | Optional | Upload token for the `hakula` Cachix cache | +| `CLOUDFLARE_API_TOKEN` | When `deploy: true` | Cloudflare API token for preview and production deployments | +| `CLOUDFLARE_ACCOUNT_ID` | Optional | Cloudflare account that owns the Worker if Wrangler omits `account_id` | + +See [Check out source](ci.md#check-out-source) and [Cache builds](ci.md#cache-builds) for how `sparse-checkout`, `submodules`, and `CACHIX_AUTH_TOKEN` behave across reusable workflows. + +## Clean up pull request previews + +When `deploy: true`, add a separate workflow on `pull_request_target: closed` that calls [`docs-cleanup.yml`](../.github/workflows/docs-cleanup.yml) to delete the `pr-` Workers preview for same-repo, non-Dependabot pull requests. + +```yaml +# .github/workflows/docs-cleanup.yml +name: Docs Preview Cleanup + +on: + pull_request_target: + types: [closed] + +permissions: + contents: read + pull-requests: read + +jobs: + cleanup: + uses: hakulab/devkit/.github/workflows/docs-cleanup.yml@v3 + with: + directory: docs + shell: docs + secrets: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} +``` + +`docs-cleanup.yml` accepts the same `directory`, `shell`, `sparse-checkout`, and `submodules` inputs as `docs.yml`, requires `CLOUDFLARE_API_TOKEN`, and accepts an optional `CLOUDFLARE_ACCOUNT_ID`. Grant `contents: read` and `pull-requests: read` and omit workflow-level `cancel-in-progress: true` so a running cleanup can finish. The workflow uses the same `preview-` (`queue: max`) concurrency group as `deploy-preview` so preview deployments and cleanups serialize, and runs only against the trusted base checkout and lockfile. + +## Renovate updates for Astro and Starlight + +Extending the [shared Renovate preset](renovate.md#use-the-preset) (`github>hakulab/devkit#v3`, defined in [`default.json`](../default.json)) groups Astro (`astro`, `@astrojs/*`) and Starlight (`starlight-*`) updates by update type. + +| Update type | Group name | Automerge | +| ----------- | ----------------------------- | --------- | +| Patch | `Node dependencies` | Enabled | +| Minor | `Astro and Starlight` | Disabled | +| Major | `Astro and Starlight (major)` | Disabled | diff --git a/nix/lib.nix b/nix/lib.nix index d5ef0cd..5b20c6f 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -43,6 +43,30 @@ let text = "exec uv sync --locked"; }; + # ------------------------------------------------------------------------------------------------ + # Docs shell + # ------------------------------------------------------------------------------------------------ + mkDocsShell = + { + name ? "docs-website", + extraPackages ? [ ], + }: + pkgs.mkShell { + inherit name; + packages = + builtins.attrValues nodeToolchain + ++ [ + pkgs.lychee + pkgs.playwright-driver.browsers + ] + ++ extraPackages; + env.PLAYWRIGHT_BROWSERS_PATH = "${pkgs.playwright-driver.browsers}"; + # Export in shellHook so outer mkShell inputsFrom compositions inherit the path. + shellHook = '' + export PLAYWRIGHT_BROWSERS_PATH=${pkgs.lib.escapeShellArg pkgs.playwright-driver.browsers} + ''; + }; + # ------------------------------------------------------------------------------------------------ # Nushell tools # ------------------------------------------------------------------------------------------------ @@ -88,6 +112,7 @@ in inherit dprint dprintConfig + mkDocsShell mkNuApplication nodeTool nodeToolchain diff --git a/scripts/workers.nu b/scripts/workers.nu index 81a0fdf..35257a5 100755 --- a/scripts/workers.nu +++ b/scripts/workers.nu @@ -9,9 +9,15 @@ def --wrapped pnpm [...args: string] { error make {msg: "Set CLOUDFLARE_API_TOKEN on the Workers step"} } + let shell = if ($env.WORKER_DEV_SHELL? | is-not-empty) { + [$".#($env.WORKER_DEV_SHELL)"] + } else { + [] + } + hide-env GH_TOKEN ( - ^nix develop -c + ^nix develop ...$shell -c pnpm --dir $env.WORKER_DIRECTORY ...$args