Skip to content

docs: Improve defensibility and sourcing across content #167

docs: Improve defensibility and sourcing across content

docs: Improve defensibility and sourcing across content #167

Workflow file for this run

name: Deploy Zensical to GitHub Pages
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Build site
run: zensical build
- name: Generate sitemap.xml
run: |
python - << 'PY'
import os
from datetime import datetime
import tomllib
import xml.etree.ElementTree as ET
# Extract site_url from zensical.toml
site_url = ''
with open('zensical.toml', 'rb') as f:
config = tomllib.load(f)
site_url = config.get('project', {}).get('site_url', '')
base_url = (site_url or '').rstrip('/') + '/'
site_dir = 'site'
urlset = ET.Element('urlset', xmlns='http://www.sitemaps.org/schemas/sitemap/0.9')
for root, _, files in os.walk(site_dir):
for name in files:
if not name.endswith('.html'):
continue
file_path = os.path.join(root, name)
rel_path = os.path.relpath(file_path, site_dir)
if rel_path == '404.html':
continue
# Build URL
loc = base_url
if rel_path == 'index.html':
pass
else:
rel_url = rel_path.replace(os.sep, '/')
if rel_url.endswith('/index.html'):
rel_url = rel_url[:-10]
loc += rel_url
url = ET.SubElement(urlset, 'url')
ET.SubElement(url, 'loc').text = loc
# Add lastmod from file modification time
mtime = os.path.getmtime(file_path)
lastmod = datetime.fromtimestamp(mtime).strftime('%Y-%m-%d')
ET.SubElement(url, 'lastmod').text = lastmod
# Add priority based on path
if rel_path == 'index.html':
priority = '1.0'
elif 'governance-templates' in rel_path or 'safety-standards' in rel_path:
priority = '0.8'
elif 'business-resources' in rel_path:
priority = '0.7'
else:
priority = '0.5'
ET.SubElement(url, 'priority').text = priority
# Add changefreq
ET.SubElement(url, 'changefreq').text = 'monthly'
ET.ElementTree(urlset).write(os.path.join(site_dir, 'sitemap.xml'), encoding='utf-8', xml_declaration=True)
PY
- name: Copy root-level files
run: |
cp robots.txt site/
cp llms.txt site/
cp llms-full.txt site/
- name: Verify build
run: |
test -f site/index.html || { echo "Error: site/index.html not found"; exit 1; }
test -f site/sitemap.xml || { echo "Error: site/sitemap.xml not found"; exit 1; }
test -f site/robots.txt || { echo "Error: site/robots.txt not found"; exit 1; }
test -f site/llms.txt || { echo "Error: site/llms.txt not found"; exit 1; }
echo "Build verification passed"
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- name: Configure GitHub Pages
uses: actions/configure-pages@v5
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4