on:
  push:
  schedule:
    - cron: 0 10 13 * *

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php:
          - 7.2
          - 7.3
          - 7.4
        composer:
          - ""
          - "--prefer-lowest"

    steps:
      - uses: actions/checkout@v2

      - name: Create Docker Container
        run: |
          docker build . -t ci-image --build-arg PHP_VERSION=${{ matrix.php }}
          docker run --interactive --detach --volume ${{ github.workspace }}:/app --name ci ci-image

      - name: Install Dependencies
        run: docker exec ci composer update --no-interaction --no-ansi --prefer-dist ${{ matrix.composer }}

      - name: PHPUnit
        run: docker exec ci vendor/bin/phpunit

      - name: PHPStan
        run: |
          docker exec ci vendor/bin/phpstan analyse --level=max src
          docker exec ci vendor/bin/phpstan analyse --level=max --configuration=phpstan-tests.neon tests

      - name: Coding Standards
        run: docker exec ci vendor/bin/phpcs --standard=phpcs.xml src tests

      - name: Check Dependencies
        run: docker exec ci vendor/bin/composer-require-checker --config-file=.require.json

      - name: Composer Validate
        run: docker exec ci composer validate --strict

on:
  push:
  pull_request:
  schedule:
    - cron: 0 10 13 * *

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        php:
          - "7.2"
          - "7.3"
          - "7.4"
        composer:
          - ""
          - "--prefer-lowest"

    steps:
      - uses: actions/checkout@v2

      - name: Create Docker Container
        run: |
          docker build . -t ci-image --build-arg PHP_VERSION=${{ matrix.php }}
          docker run --interactive --detach --volume ${{ github.workspace }}:/app --name ci ci-image

      - name: Install Dependencies
        run: docker exec ci composer update --no-interaction --no-ansi --prefer-dist ${{ matrix.composer }}

      - name: PHPUnit
        run: docker exec ci vendor/bin/phpunit

      - name: PHPStan
        run: |
          docker exec ci vendor/bin/phpstan analyse --level=max src
          docker exec ci vendor/bin/phpstan analyse --level=max --configuration=phpstan-tests.neon tests

      - name: Coding Standards
        run: docker exec ci vendor/bin/phpcs --standard=phpcs.xml src tests

      - name: Check Dependencies
        run: docker exec ci vendor/bin/composer-require-checker --config-file=.require.json

      - name: Composer Validate
        run: docker exec ci composer validate --strict

Tidy up the build check and ensure it runs for pull requests
Tidy up the build check and ensure it runs for pull requests
