-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (59 loc) · 1.84 KB
/
Copy pathdeploy-docs-pages.yml
File metadata and controls
75 lines (59 loc) · 1.84 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
name: Deploy Docs To GitHub Pages
on:
push:
branches:
- main
paths:
- docs/**
- scripts/build-docs-pages.js
- .github/workflows/deploy-docs-pages.yml
workflow_dispatch:
permissions:
contents: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 22
cache: npm
- name: Install Dependencies
run: npm ci
- name: Build Docs Site
run: node scripts/build-docs-pages.js
- name: Publish To gh-pages Branch
shell: bash
run: |
set -euo pipefail
PUBLISH_DIR="${RUNNER_TEMP}/gh-pages"
# Clean up stale worktree path from prior attempts.
git worktree remove --force "$PUBLISH_DIR" 2>/dev/null || true
rm -rf "$PUBLISH_DIR"
git fetch origin gh-pages || true
if git show-ref --verify --quiet refs/remotes/origin/gh-pages; then
git worktree add "$PUBLISH_DIR" refs/remotes/origin/gh-pages
else
git worktree add -B gh-pages "$PUBLISH_DIR"
fi
# Keep worktree git metadata intact.
rsync -av --delete --exclude='.git' .site/ "$PUBLISH_DIR"/
touch "$PUBLISH_DIR/.nojekyll"
cd "$PUBLISH_DIR"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add --all
if git diff --cached --quiet; then
echo "No docs changes to publish"
exit 0
fi
git commit -m "Deploy docs for ${GITHUB_SHA}"
git push origin HEAD:gh-pages