name: Docs build and release

on:
  push:
    branches: [main,feature/GUUI-3522-subsetter-component]

jobs:
  build_deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout latest code
        uses: actions/checkout@v3
        with:
          fetch-depth: 0

      - name: Setup NodeJS v22
        uses: actions/setup-node@v3
        with:
          node-version: 22
          cache: "npm"
          cache-dependency-path: package-lock.json
      
      - name: Install dependencies
        run: npm install

      - name: Build project
        run: npm run build
        env:
          DOCS_PATH_PREFIX: /components

      - name: Release Github Pages
        uses: peaceiris/actions-gh-pages@v3
        with:
          publish_dir: _site
          publish_branch: gh-pages
          github_token: ${{ secrets.DEPLOY_TOKEN }}