name: Deploy static content to Pages

on:
  push:
    branches: ['master']

  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

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

jobs:
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Node
        uses: actions/setup-node@v3
        with:
          node-version: 21
      - name: Orbits Install dependencies
        run: npm ci
        working-directory: orbits
      - name: Orbits Build
        run: npx vite build
        working-directory: orbits
      - name: recBubbles Install dependencies
        run: npm ci
        working-directory: recBubbles
      - name: recBubbles Build
        run: npx vite build
        working-directory: recBubbles
      - name: balls Install dependencies
        run: npm ci
        working-directory: balls
      - name: balls Build
        run: npx vite build
        working-directory: balls
      - name: fireWorks Install dependencies
        run: npm ci
        working-directory: fireWorks
      - name: fireWorks Build
        run: npx vite build
        working-directory: fireWorks
      - name: bubbles Install dependencies
        run: npm ci
        working-directory: bubbles
      - name: bubbles Build
        run: npx vite build
        working-directory: bubbles
      - name: circleBs Install dependencies
        run: npm ci
        working-directory: circleBs
      - name: circleBs Build
        run: npx vite build
        working-directory: circleBs
      - name: clusterFilter Install dependencies
        run: npm ci
        working-directory: clusterFilter
      - name: clusterFilter Build
        run: npx vite build
        working-directory: clusterFilter
      - name: collatzConjecture Install dependencies
        run: npm ci
        working-directory: collatzConjecture
      - name: collatzConjecture Build
        run: npx vite build
        working-directory: collatzConjecture
      - name: dotLines Install dependencies
        run: npm ci
        working-directory: dotLines
      - name: dotLines Build
        run: npx vite build
        working-directory: dotLines
      - name: survivors install dependencies
        run: npm ci
        working-directory: absurd-survivors
      - name: survivors build
        run: npx vite build
        working-directory: absurd-survivors
      - name: Move index
        run: cp index.html dist/
      - name: Move overview images
        run: mkdir -p dist/img && cp img/* dist/img
      - name: Setup Pages
        uses: actions/configure-pages@v3
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: './dist'
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4