name: Build Webpage
on:
  push:
    branches: [main]
    # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths
    # if [[ ${changed_file} == "CHANGELOG.md" ]] || [[ ${changed_file} = screenshots* ]] || [[ ${changed_file} = webpage* ]] || [[ ${changed_file} = ".github/workflows/build-webpage.yml" ]] ;
    paths:
      - ".github/workflows/build-webpage.yml"
  pull_request:
    branches: [main]
    # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-including-paths
    # if [[ ${changed_file} == "CHANGELOG.md" ]] || [[ ${changed_file} = screenshots* ]] || [[ ${changed_file} = webpage* ]] || [[ ${changed_file} = ".github/workflows/build-webpage.yml" ]] ;
    paths:
      - "CHANGELOG.md"
      - "screenshots/**"
      - "webpage/**"

defaults:
  run:
    working-directory: webpage

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v6
      - id: files
        uses: masesgroup/retrieve-changed-files@v3
        with:
          format: "csv"
      - name: Use Node.js
        uses: actions/setup-node@v6
        with:
          node-version: "20"
      - run: npm install
      - run: npm run build
