feat(docs): add dark mode theme #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Docs | |
| on: | |
| push: | |
| branches: [legacy] | |
| 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 |