-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (118 loc) · 4.37 KB
/
deploy.yml
File metadata and controls
132 lines (118 loc) · 4.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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
with:
fetch-depth: 0
- 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: Generate updates.json
run: python scripts/generate_updates.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; }
test -f site/llms-full.txt || { echo "Error: site/llms-full.txt not found"; exit 1; }
test -f site/updates.json || { echo "Error: site/updates.json 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