forked from mezo-org/documentation
-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (67 loc) · 2.43 KB
/
pages.yml
File metadata and controls
76 lines (67 loc) · 2.43 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
name: Deploy to GitHub Pages
on:
push:
branches:
- main
- "crew/**"
- "docs/**" # fork README's convention for doc branches
workflow_dispatch:
permissions:
contents: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Lunaria needs full git history to compute i18n diff
- name: Compute deploy path
id: paths
env:
REF: ${{ github.ref }}
run: |
if [ "$REF" = "refs/heads/main" ]; then
echo "dest=" >> "$GITHUB_OUTPUT"
echo "base=/mezo-docs/" >> "$GITHUB_OUTPUT"
else
BRANCH="${REF#refs/heads/}"
# Sanitize: allow only [A-Za-z0-9_-]; replace everything else with '-'
SAFE=$(printf '%s' "$BRANCH" | tr -c 'A-Za-z0-9_-' '-' | sed 's/--*/-/g; s/^-//; s/-$//')
if [ -z "$SAFE" ]; then
echo "Refusing to deploy: sanitized branch name is empty" >&2
exit 1
fi
echo "dest=preview/${SAFE}" >> "$GITHUB_OUTPUT"
echo "base=/mezo-docs/preview/${SAFE}/" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-node@v4
with:
node-version: "22"
cache: npm
- run: npm ci
- name: Build Astro site
env:
ASTRO_SITE: https://vativ.github.io
ASTRO_BASE: ${{ steps.paths.outputs.base }}
# 1. process-gitbook regenerates locale MDX with correct relative
# import paths (upstream's package.json build does this first).
# 2. Transient commit clears the dirty working tree — Lunaria (Starlight
# i18n plugin) refuses to run with uncommitted changes. Commit is
# local to the runner only; never pushed.
# 3. astro build renders the site to dist/.
run: |
npm run process-gitbook
git -c user.email=ci@local -c user.name=ci commit -am "ci: regen" --allow-empty --quiet || true
npx astro build
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./dist
destination_dir: ${{ steps.paths.outputs.dest }}
keep_files: true
user_name: github-actions[bot]
user_email: github-actions[bot]@users.noreply.github.com