name: Docs - Build (& Deploy)

on:
  push:
    branches:
    - main
  pull_request:
    branches:
    - main
  workflow_dispatch:

jobs:
  build-test-deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      with: { persist-credentials: false }
    - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
      with:
        node-version-file: '.nvmrc'

    - name: Install NPM packages
      run: npm ci

    - name: Build style spec
      run: |
        npm run generate-style-spec
        npm run generate-typings

    - name: Build docs
      run: npm run docs


    - name: Deploy
      if: github.ref == 'refs/heads/main'
      uses: JamesIves/github-pages-deploy-action@d92aa235d04922e8f08b40ce78cc5442fcfbfa2f # v4.8.0
      with:
        branch: gh-pages
        folder: site
