name: Build

on:
  pull_request:
    types: [opened, synchronize, reopened]
  workflow_dispatch:

env:
  PHP_VERSION: '8.3'                  # set this to the PHP version to use
  COMPOSER_ALLOW_SUPERUSER: 1

permissions:
  contents: read

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: Setup PHP
        uses: shivammathur/setup-php@7c0b4c8c8ebed23eca9ec2802474895d105b11bc
        with:
          php-version: ${{ env.PHP_VERSION }}

      - name: Run composer install if composer.json exists
        run: | 
          rm composer.lock
          composer validate --no-check-publish

      - name: Set up Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '16'

      - name: Install dependencies
        run: npm install

      - name: Build CSS
        run: npm run build:css
