name: Deploy Docs (Production)

on:
  push:
    branches:
      - master
  workflow_dispatch:

permissions:
  contents: write

concurrency:
  group: pages-production
  cancel-in-progress: true

jobs:
  build-and-deploy:
    name: Build and deploy docs
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'npm'

      - name: Install dependencies
        run: npm ci

      - name: Build docs site
        run: npm run publish

      - name: Deploy production docs to gh-pages root
        uses: peaceiris/actions-gh-pages@v4
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_branch: gh-pages
          publish_dir: ./docs
          keep_files: true
          cname: keyrune.andrewgioia.com
