-
Notifications
You must be signed in to change notification settings - Fork 49
102 lines (93 loc) · 3.81 KB
/
Copy pathdocs.yml
File metadata and controls
102 lines (93 loc) · 3.81 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
name: Deploy Docs
on:
push:
branches: [master]
paths:
- "docs/**"
- ".github/workflows/docs.yml"
# Manual run from the Actions tab (no commit needed)
workflow_dispatch:
# Only needs to read this repo; the push to the hub uses HUB_DEPLOY_TOKEN.
permissions:
contents: read
concurrency:
group: docs-deploy-legacy
cancel-in-progress: true
jobs:
deploy:
name: Build & publish docs
runs-on: ubuntu-latest
steps:
- name: Checkout MenuAPI
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies (legacy)
run: npm ci
working-directory: docs/legacy
- name: Install dependencies (redm)
run: npm ci
working-directory: docs/redm
# Build each doc set once per URL prefix. Astro bakes the base into the
# output URLs, so /menuapi and /mapi need separate builds. The MenuAPI repo
# is served from the TomGrobbe.github.io hub as lowercase /menuapi/ and, for
# backwards compatibility with the old docs, also at /mapi/.
- name: Build all variants
run: |
set -e
build() {
echo "== building $1 with base $2 -> $3 =="
(cd "$1" && DOCS_BASE="$2" npm run build)
mkdir -p "$3"
cp -r "$1/dist/." "$3/"
}
rm -rf _site
build docs/legacy /menuapi/legacy _site/menuapi/legacy
build docs/legacy /mapi/legacy _site/mapi/legacy
build docs/redm /menuapi/redm _site/menuapi/redm
build docs/redm /mapi/redm _site/mapi/redm
# chooser landing + favicon at each prefix root. The enhanced/ docs are
# deployed separately from the fivem-enhanced branch, so we don't build
# or touch them here (see the Publish step).
for P in menuapi mapi; do
cp docs/landing/index.html "_site/$P/index.html"
cp docs/legacy/public/favicon.png "_site/$P/favicon.png"
done
# Publish into the hub repo. GitHub Pages serves a project site at the
# case-sensitive /RepoName/ path, so lowercase /menuapi/ (and the legacy
# /mapi/) come from pushing the built site into the user/hub site instead.
- name: Publish to hub site
env:
HUB_TOKEN: ${{ secrets.HUB_DEPLOY_TOKEN }}
run: |
set -euo pipefail
if [ -z "${HUB_TOKEN}" ]; then
echo "::error::HUB_DEPLOY_TOKEN secret is not set. See docs/README.md for setup."
exit 1
fi
git clone --depth 1 --branch main \
"https://x-access-token:${HUB_TOKEN}@github.com/TomGrobbe/TomGrobbe.github.io.git" hub
# Replace the MenuAPI folders, but keep the hub index.html, CNAME,
# .nojekyll and other product folders (e.g. /vmenu/) intact. Within each
# prefix, also keep the enhanced/ subfolder: those docs are deployed from
# the fivem-enhanced branch, so wiping the whole prefix here would clobber
# them (last push wins). Remove only what this branch owns, then copy in.
for P in menuapi mapi; do
mkdir -p "hub/$P"
find "hub/$P" -mindepth 1 -maxdepth 1 ! -name enhanced -exec rm -rf {} +
cp -r "_site/$P/." "hub/$P/"
done
# Disable Jekyll so Astro's _astro/ asset folder is served (not skipped).
touch hub/.nojekyll
cd hub
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
if git diff --cached --quiet; then
echo "No documentation changes to publish."
else
git commit -m "Deploy MenuAPI docs"
git push origin main
fi