From b760c00310f3318e07df91b03147506dd6dbdf88 Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Sun, 22 Mar 2026 06:09:57 -0400 Subject: [PATCH 1/2] ci: add comments and clean full working tree in build-docs action Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/actions/build-docs/action.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml index 28d5ae0..6e45fb0 100644 --- a/.github/actions/build-docs/action.yml +++ b/.github/actions/build-docs/action.yml @@ -16,10 +16,14 @@ runs: steps: - shell: bash run: | - # Use github.action_path so the script always comes from the action's - # source (trusted main branch), not the checked-out working directory - # (which may contain untrusted PR code). + # Update the site url. uv run --group docs python "${{ github.action_path }}/override_site_url.py" "${{ inputs.subdir }}" + + # Build the docs. uv run --group docs zensical build --clean + + # Move the docs to the output directory. mv site /tmp/built-site - git checkout -- zensical.toml + + # Leave the working directory clean for the next action. + git checkout -- . From 8a9c2b88ea90e7e3505e2c2edda654d7f9bb2bad Mon Sep 17 00:00:00 2001 From: Tai Sakuma Date: Sun, 22 Mar 2026 06:23:42 -0400 Subject: [PATCH 2/2] refactor: define SITE_DIR once in PR preview workflow Extract /tmp/built-site into a workflow-level env var and pass it to build-docs, upload/download-artifact, and deploy-to-gh-pages. Add site-dir input to build-docs action. Co-Authored-By: Claude Opus 4.6 (1M context) --- .github/actions/build-docs/action.yml | 7 +++++-- .github/workflows/docs-pr-preview.yml | 10 +++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml index 6e45fb0..59ec00e 100644 --- a/.github/actions/build-docs/action.yml +++ b/.github/actions/build-docs/action.yml @@ -5,11 +5,14 @@ inputs: subdir: description: Subdirectory to deploy to (e.g., dev, 1.0.0, pr/3) required: true + site-dir: + description: Output directory for the built site + default: /tmp/built-site outputs: site-dir: description: Path to the built site - value: /tmp/built-site + value: ${{ inputs.site-dir }} runs: using: composite @@ -23,7 +26,7 @@ runs: uv run --group docs zensical build --clean # Move the docs to the output directory. - mv site /tmp/built-site + mv site "${{ inputs.site-dir }}" # Leave the working directory clean for the next action. git checkout -- . diff --git a/.github/workflows/docs-pr-preview.yml b/.github/workflows/docs-pr-preview.yml index 187960e..b0357eb 100644 --- a/.github/workflows/docs-pr-preview.yml +++ b/.github/workflows/docs-pr-preview.yml @@ -7,6 +7,9 @@ on: pull_request_target: types: [opened, synchronize, reopened] +env: + SITE_DIR: /tmp/built-site + concurrency: group: docs-deploy cancel-in-progress: false @@ -34,11 +37,12 @@ jobs: id: build with: subdir: pr/${{ github.event.number }} + site-dir: ${{ env.SITE_DIR }} - uses: actions/upload-artifact@v4 with: name: docs-preview - path: /tmp/built-site + path: ${{ env.SITE_DIR }} retention-days: 1 deploy: @@ -55,14 +59,14 @@ jobs: - uses: actions/download-artifact@v4 with: name: docs-preview - path: /tmp/built-site + path: ${{ env.SITE_DIR }} # Reference the action from @main so deploy logic always comes from the # trusted main branch. - uses: TaiSakuma/improved-octo-fortnight/.github/actions/deploy-to-gh-pages@main id: deploy with: - site-dir: /tmp/built-site + site-dir: ${{ env.SITE_DIR }} target: pr/${{ github.event.number }} commit-message: "Deploy PR #${{ github.event.number }} preview"