Skip to content

Commit f6875ad

Browse files
committed
feat: add GitHub Actions workflow for deploying ShellDocs to GitHub Pages
- Introduced a new workflow in deploy-pages.yml to automate the deployment of the ShellDocs documentation site to GitHub Pages. - Configured triggers for deployment on pushes to the main branch and manual dispatch. - Implemented build steps to generate a static site using the shelldocs CLI, including handling of custom domains and Jekyll settings. - Ensured proper permissions and concurrency management for seamless deployment.
1 parent 67ea04a commit f6875ad

1 file changed

Lines changed: 113 additions & 0 deletions

File tree

‎.github/workflows/deploy-pages.yml‎

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Publishes the ShellDocs docs site to GitHub Pages (custom domain:
2+
# shelldocs.shellui.dev). Two triggers: every push to `main`, and manual
3+
# via workflow_dispatch when you want to re-deploy without a code change.
4+
#
5+
# Uses the modern GitHub Pages deploy flow (`actions/upload-pages-artifact`
6+
# + `actions/deploy-pages`) — no `gh-pages` branch commits, no third-party
7+
# actions, no PAT juggling. Deploy runs as the Pages OIDC identity in the
8+
# `github-pages` Environment.
9+
#
10+
# ─── Build step ────────────────────────────────────────────────────────
11+
# `shelldocs build` (as of 0.1.5-alpha) does the real work: `dotnet
12+
# publish`, then launches the published Blazor Server app on a loopback
13+
# port, walks NavigationGraph.AllUrls to enumerate every route, HTTP-GETs
14+
# each URL and saves the rendered HTML per route, then merges
15+
# publish/wwwroot/ (framework assets + shelldocs.js + tokens CSS) on top.
16+
# Output is a real static site — every URL is a prerendered HTML file,
17+
# no .NET host needed at runtime. Server-mode Blazor's client-side JS
18+
# still boots (shelldocs.js drives theme/search/tabs/copy/collapse
19+
# without SignalR), so interactive chrome keeps working on Pages.
20+
21+
name: Deploy to GitHub Pages
22+
23+
on:
24+
push:
25+
branches: [main]
26+
workflow_dispatch:
27+
28+
# GH Pages only serves the most-recently-deployed artifact. Cancel any
29+
# in-progress deploy when a new push lands so the newest commit wins
30+
# instead of racing an older one to completion.
31+
concurrency:
32+
group: pages
33+
cancel-in-progress: true
34+
35+
# Required by the deploy-pages action:
36+
# pages: write — upload the artifact + trigger the deploy
37+
# id-token: write — sign the deploy via OIDC (no PAT needed)
38+
# contents: read — checkout
39+
permissions:
40+
pages: write
41+
id-token: write
42+
contents: read
43+
44+
jobs:
45+
build:
46+
name: Build static site
47+
runs-on: ubuntu-latest
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Setup .NET
52+
uses: actions/setup-dotnet@v4
53+
with:
54+
# Reads global.json — currently pinned to a 10.0 preview.
55+
global-json-file: global.json
56+
57+
# Pin the CLI version to the same version the site's PackageReferences
58+
# use. Prevents a floating latest-prerelease install from silently
59+
# shifting the prerender behaviour under our feet mid-release-cycle.
60+
- name: Install shelldocs CLI
61+
run: dotnet tool install -g ShellDocs.CLI --version 0.1.6-alpha
62+
63+
# Restore explicitly so the `shelldocs build`'s embedded `dotnet
64+
# publish` doesn't spend the first run downloading every package
65+
# under a subprocess where its progress output is buried.
66+
- name: Restore
67+
run: dotnet restore ShellDocs.Site.csproj
68+
69+
# `shelldocs build` produces the full static site into `./publish/`
70+
# by default: prerendered HTML for every route + merged framework
71+
# assets. --spa-fallback copies index.html to 404.html so GH Pages
72+
# serves the app shell for any URL a bot / typo hits that doesn't
73+
# correspond to a prerendered route. --site-url (added in 0.1.6-alpha)
74+
# emits a sitemap.xml + robots.txt at the site root and injects
75+
# og:title / og:description / og:url / og:type into every rendered
76+
# page's <head> so link previews on social / chat look right. No
77+
# --base-href flag: we're on a custom root domain
78+
# (shelldocs.shellui.dev), so `<base href="/">` from the source is
79+
# already correct.
80+
- name: Build static site
81+
run: shelldocs build --spa-fallback --site-url https://shelldocs.shellui.dev
82+
83+
# Custom domain: GH Pages reads a `CNAME` file at the site root and
84+
# keeps the domain wired across deploys. Written here (not committed
85+
# to the repo) so nothing in source needs to know the deploy URL.
86+
- name: Write CNAME
87+
run: echo "shelldocs.shellui.dev" > publish/CNAME
88+
89+
# `.nojekyll` disables GitHub's default Jekyll build. Blazor's output
90+
# includes files whose names start with `_` (`_framework/`,
91+
# `_content/`) — Jekyll would silently exclude those from the served
92+
# site, breaking every JS/CSS asset. Ship the flag file to opt out.
93+
- name: Disable Jekyll
94+
run: touch publish/.nojekyll
95+
96+
- name: Upload Pages artifact
97+
uses: actions/upload-pages-artifact@v3
98+
with:
99+
path: publish
100+
101+
deploy:
102+
name: Deploy to Pages
103+
needs: build
104+
runs-on: ubuntu-latest
105+
environment:
106+
# The `github-pages` environment is auto-created by the deploy
107+
# action; its URL is where the deploy landed.
108+
name: github-pages
109+
url: ${{ steps.deployment.outputs.page_url }}
110+
steps:
111+
- name: Deploy
112+
id: deployment
113+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)