name: build

on: push

jobs:
  files-changed:
    name: Detect File Changes - build
    runs-on: ubuntu-latest
    outputs:
      build: ${{ steps.filter.outputs.build }}
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
      - uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
        id: filter
        with:
          filters: |
            build:
              - '.github/workflows/**/*'
              - 'backend/**/*'

  build:
    if: needs.files-changed.outputs.build == 'true'
    name: Build
    needs: files-changed
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.1.7
      - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.0.3
        with:
          node-version-file: './.tool-versions'
      - name: Install Dependencies & Build Library
        run: |
          npm install
          npm run build
        working-directory: ./backend