name: build-frontend

on:
  push:
    branches: [master]
    paths:
      - "frontend/**"

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node
        uses: actions/setup-node@v3.5.1
        with:
          node-version: 14.x

      - name: Get npm cache directory
        id: npm-cache
        run: |
          echo "::set-output name=dir::$(npm config get cache)"

      - name: Setup npm cache
        uses: actions/cache@v3
        with:
          path: ${{ steps.npm-cache.outputs.dir }}
          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-node-

      - name: Install Dependencies
        working-directory: frontend
        run: npm install

      - name: Build source
        working-directory: frontend
        run: npx quasar build -m spa
