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
17 changes: 17 additions & 0 deletions .github/actions/build-docs/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Build docs
description: Build docs with site_url overridden for subdirectory deployment

inputs:
subdir:
description: Subdirectory to deploy to (e.g., dev, 1.0.0, pr/3)
required: true

runs:
using: composite
steps:
- shell: bash
run: |
uv run --group docs python .github/scripts/override_site_url.py "${{ inputs.subdir }}"
uv run --group docs zensical build --clean
cp -r site /tmp/built-site
git checkout -- zensical.toml
9 changes: 8 additions & 1 deletion .github/actions/deploy-to-gh-pages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ inputs:
description: Commit message
required: true

outputs:
url:
description: Default GitHub Pages URL for the deployed subdirectory
value: ${{ steps.deploy.outputs.url }}

runs:
using: composite
steps:
- shell: bash
- id: deploy
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
Expand All @@ -32,3 +38,4 @@ runs:
git add .nojekyll "$TARGET"
git diff --cached --quiet || git commit -m "${{ inputs.commit-message }}"
git push origin gh-pages
echo "url=https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/${TARGET}/" >> "$GITHUB_OUTPUT"
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@
from pathlib import Path
import tomlkit

INPUT_PATH = Path('zensical.toml')
OUTPUT_PATH = Path('zensical.local.toml')
CONFIG_PATH = Path('zensical.toml')


def main():
config = tomlkit.loads(INPUT_PATH.read_text())
config = tomlkit.loads(CONFIG_PATH.read_text())
url = config.get('project', {}).get('site_url')
if url:
subdir = sys.argv[1]
new_url = url.rstrip('/') + '/' + subdir.strip('/') + '/'
config['project']['site_url'] = new_url
OUTPUT_PATH.write_text(tomlkit.dumps(config))
CONFIG_PATH.write_text(tomlkit.dumps(config))


main()
18 changes: 5 additions & 13 deletions .github/workflows/docs-pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,22 @@ jobs:

- uses: astral-sh/setup-uv@v7

- name: Build docs
run: |
uv run --group docs python scripts/override_site_url.py "pr/${{ github.event.number }}"
uv run --group docs zensical build --clean --config-file zensical.local.toml
cp -r site /tmp/built-site

- name: Get preview URL
id: preview
run: |
url=$(uv run --group docs python -c "import tomlkit; print(tomlkit.loads(open('zensical.local.toml').read()).get('project', {}).get('site_url', ''))")
echo "url=${url}" >> "$GITHUB_OUTPUT"
- uses: ./.github/actions/build-docs
with:
subdir: pr/${{ github.event.number }}

- uses: ./.github/actions/deploy-to-gh-pages
id: deploy
with:
target: pr/${{ github.event.number }}
commit-message: "Deploy PR #${{ github.event.number }} preview"

- name: Post or update PR comment
if: steps.preview.outputs.url != ''
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- docs-preview -->';
const url = '${{ steps.preview.outputs.url }}';
const url = '${{ steps.deploy.outputs.url }}';
const body = `${marker}\n📖 Docs preview: ${url}`;
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/docs-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ jobs:

- uses: astral-sh/setup-uv@v7

- name: Build docs
run: |
uv run --group docs python scripts/override_site_url.py "${{ steps.version.outputs.version }}"
uv run --group docs zensical build --clean --config-file zensical.local.toml
cp -r site /tmp/built-site
- uses: ./.github/actions/build-docs
with:
subdir: ${{ steps.version.outputs.version }}

- uses: ./.github/actions/deploy-to-gh-pages
with:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ jobs:

- uses: astral-sh/setup-uv@v7

- name: Build docs
run: |
uv run --group docs python scripts/override_site_url.py dev
uv run --group docs zensical build --clean --config-file zensical.local.toml
cp -r site /tmp/built-site
- uses: ./.github/actions/build-docs
with:
subdir: dev

- uses: ./.github/actions/deploy-to-gh-pages
with:
Expand Down
Loading