name: Publish Docs

on:
  workflow_call:

jobs:
  publish_docs:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v4

      - uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Cache NPM modules
        id: npm-cache
        uses: actions/cache@v4
        with:
          path: node_modules
          key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-npm-

      - name: Install dependencies
        run: npm ci

      - name: Build Example/Docs
        run: |
          npm run build
          touch build/.nojekyll

      - name: Publish to GitHub
        uses: JamesIves/github-pages-deploy-action@v4.7.1
        with:
          branch: gh-pages
          folder: build
