Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,28 @@ 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
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
mv site /tmp/built-site
git checkout -- zensical.toml

# Move the docs to the output directory.
mv site "${{ inputs.site-dir }}"

# Leave the working directory clean for the next action.
git checkout -- .
10 changes: 7 additions & 3 deletions .github/workflows/docs-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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"

Expand Down
Loading