Skip to content

Commit e76fd25

Browse files
ci: publish GitHub Pages preview of the catalog (#13)
Implements #9. Adds `.github/workflows/pages.yml` — builds the catalog from `apps.json` and deploys a browsable preview to **GitHub Pages** on push to `master` (+ `workflow_dispatch`). ## How it works - **Standalone build** (`npm run build`, non-headless) so the preview has the chrome nav bar + app switcher and is usable on its own — not the headless/web-fragment output. - **Base already matches**: the project-site URL `https://absaoss.github.io/knowledge-base/` lines up with Astro's `base: /knowledge-base`, so links/assets resolve unchanged. - **Fragment-prefix rewrite**: static Pages has no gateway/nginx to rewrite `/__wf/knowledge-base/*`, and `/__wf/*` is outside the project-site mount. A post-build step rewrites `/__wf/knowledge-base/ → /knowledge-base/` so the marketplace stylesheet resolves to `dist/style.css`. Verified: 0 `/__wf/` refs remain; all referenced paths exist under the mount. - **Hermetic**: builds from the committed fixture registry — no `GITHUB_TOKEN`/network. - Actions SHA-pinned; `permissions` limited to the Pages OIDC deploy (`pages: write`, `id-token: write`). ## Repo settings needed `configure-pages` runs with `enablement: true` to turn Pages on automatically. If org policy blocks that, enable manually: **Settings → Pages → Source: GitHub Actions**. The `github-pages` environment may also need to allow deployments from `master`. ## Notes - Deploys on merge to `master` (this PR won't deploy; it runs CI + PR-requirements only). - Registry: uses the committed fixture (`user-guide` + `guide-mirror`). Swap `apps.json` for real published apps to preview those instead. Closes #9 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents 6a0eb17 + 51174a3 commit e76fd25

1 file changed

Lines changed: 71 additions & 0 deletions

File tree

.github/workflows/pages.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Publishes a browsable preview of the catalog (from apps.json) to GitHub Pages.
2+
#
3+
# The project-site URL (https://<owner>.github.io/knowledge-base/) matches Astro's
4+
# base (/knowledge-base), so links resolve with no extra config. The build is
5+
# hermetic (vendored fixture via apps.json) — no GITHUB_TOKEN or network needed.
6+
#
7+
# Requires Pages enabled with Source = "GitHub Actions" (configure-pages attempts
8+
# to enable it automatically via `enablement: true`).
9+
10+
name: Deploy Pages
11+
12+
on:
13+
push:
14+
branches: [master]
15+
workflow_dispatch:
16+
17+
# Least privilege for Pages deployment via OIDC.
18+
permissions:
19+
contents: read
20+
pages: write
21+
id-token: write
22+
23+
# Allow one concurrent deployment; let in-progress deploys finish.
24+
concurrency:
25+
group: pages
26+
cancel-in-progress: false
27+
28+
jobs:
29+
build:
30+
name: Build site
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
34+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
35+
with:
36+
node-version: '24'
37+
cache: npm
38+
- run: npm ci
39+
40+
# Standalone (non-headless) build so the preview has the chrome nav bar and
41+
# app switcher and is usable on its own. Hermetic (prebuilt fixture).
42+
- name: Build (standalone)
43+
run: npm run build
44+
45+
# Static Pages has no gateway/nginx to rewrite the fragment asset prefix,
46+
# and /__wf/* is outside the project-site mount. Point the marketplace
47+
# stylesheet at its real served path (/knowledge-base/style.css → dist/style.css).
48+
- name: Rewrite fragment asset paths for static hosting
49+
run: find dist -name '*.html' -exec sed -i 's#/__wf/knowledge-base/#/knowledge-base/#g' {} +
50+
51+
- name: Configure Pages
52+
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
53+
with:
54+
enablement: true
55+
56+
- name: Upload artifact
57+
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
58+
with:
59+
path: dist
60+
61+
deploy:
62+
name: Deploy to Pages
63+
needs: build
64+
runs-on: ubuntu-latest
65+
environment:
66+
name: github-pages
67+
url: ${{ steps.deployment.outputs.page_url }}
68+
steps:
69+
- name: Deploy to GitHub Pages
70+
id: deployment
71+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128 # v5.0.0

0 commit comments

Comments
 (0)