-
Notifications
You must be signed in to change notification settings - Fork 0
138 lines (124 loc) · 5.33 KB
/
Copy pathsite.yml
File metadata and controls
138 lines (124 loc) · 5.33 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
133
134
135
136
137
138
name: Build site
on:
# Fast path: rebuild within minutes of any data-branch push.
push:
branches: [platformio, arduino, vendors, other]
# 24-hour backstop: catches missed push triggers, GH outages, etc.
schedule:
- cron: "30 4 * * *"
# Human override.
workflow_dispatch: {}
permissions:
contents: write # for the site-branch force-push
pages: write # for actions/deploy-pages
id-token: write # for actions/deploy-pages (OIDC to GH Pages)
concurrency:
group: build-site
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
# Standard GH Pages environment binding — exposes the deployed URL as
# an output and links it from the workflow run summary.
environment:
name: github-pages
url: ${{ steps.deploy_pages.outputs.page_url }}
steps:
- name: Checkout main (tools live here)
uses: actions/checkout@v4
with: { fetch-depth: 0 }
- uses: astral-sh/setup-uv@v3
- name: Set up Node.js (for the Vite frontend build)
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: site-src/package-lock.json
- name: Configure git identity
run: |
git config user.name "fbuild-bot[site]"
git config user.email "fbuild-bot+site@users.noreply.github.com"
- name: Worktree each data branch + the site branch
id: worktrees
run: |
set -euo pipefail
mkdir -p .branches /tmp/source-shas
: > /tmp/source-shas.json
echo "{" > /tmp/source-shas.json
first=1
for b in platformio arduino vendors other; do
if git ls-remote --heads origin "$b" | grep -q .; then
git fetch origin "$b:$b"
git worktree add ".branches/$b" "$b"
sha=$(git -C ".branches/$b" rev-parse HEAD)
[ $first -eq 0 ] && echo "," >> /tmp/source-shas.json
echo " \"$b\": \"$sha\"" >> /tmp/source-shas.json
first=0
else
echo "::warning::data branch '$b' does not yet exist on remote; skipping"
fi
done
echo "}" >> /tmp/source-shas.json
cat /tmp/source-shas.json
if git ls-remote --heads origin site | grep -q .; then
git fetch origin site:site
git worktree add .site site
else
git worktree add --detach .site
(cd .site && git checkout --orphan site && git rm -rf . 2>/dev/null || true)
fi
- name: Run site builder (extractors -> merge -> sqlite -> bundle)
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
# The new orchestrator chains: extract_{vendors,arduino,platformio,
# other}.py -> merge.py -> build_sqlite.py -> templates/index.html
# + sql.js download. Errors logged under .site/errors/.
uv run --no-project --script builders/site.py \
--data-root .branches \
--out .site \
--workdir /tmp/site-work
- name: Force-push site as a fresh orphan commit
id: push_site
working-directory: .site
# Same orphan-commit pattern as the data branches: single commit,
# no history accumulation, GH UI stays at "1 commit" instead of
# growing N-behind-main forever.
run: |
set -euo pipefail
git add -A
TREE=$(git write-tree)
REMOTE_TREE=""
if git ls-remote --exit-code --heads origin site >/dev/null 2>&1; then
REMOTE_TREE=$(git rev-parse "origin/site^{tree}" 2>/dev/null || true)
fi
if [ -n "$REMOTE_TREE" ] && [ "$TREE" = "$REMOTE_TREE" ]; then
echo "tree unchanged ($TREE); skipping push"
echo "changed=false" >> "$GITHUB_OUTPUT"
exit 0
fi
ts="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
trig="${{ github.event_name }}"
NEW=$(git commit-tree "$TREE" -m "site: rebuild ($trig) ${ts}")
echo "new orphan: $NEW (tree $TREE)"
if git ls-remote --exit-code --heads origin site >/dev/null 2>&1; then
git push --force origin "$NEW:refs/heads/site"
else
git push origin "$NEW:refs/heads/site"
fi
echo "changed=true" >> "$GITHUB_OUTPUT"
# ────────────────────────────────────────────────────────────────────
# Deploy the same site/ contents to GitHub Pages. The site branch is
# kept as the auditable snapshot ("git checkout site" → exact bytes
# that are live); Pages is the public publication path. Both views
# come from the same .site/ directory the builder just wrote.
# ────────────────────────────────────────────────────────────────────
- name: Upload Pages artifact
if: steps.push_site.outputs.changed == 'true'
uses: actions/upload-pages-artifact@v3
with:
path: .site
- name: Deploy to GitHub Pages
id: deploy_pages
if: steps.push_site.outputs.changed == 'true'
uses: actions/deploy-pages@v4