# This workflow will build PRs submitted to the master branch.

name: PR Builder

on:
  pull_request:
    branches: [ master ]
  workflow_dispatch:

jobs:
  build:

    runs-on: ubuntu-latest

    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - name: Checkout
      id: checkout
      uses: actions/checkout@v2.3.3
    - name: Use Node.js ${{ matrix.node-version }}
      id: node-setup
      uses: actions/setup-node@v2.1.2
      with:
        node-version: ${{ matrix.node-version }}
    - name: Set up JDK 1.8
      id: jdk-setup
      uses: actions/setup-java@v1
      with:
        java-version: 1.8
    - name: Get npm cache directory
      id: cache-npm-modules
      uses: actions/cache@v2
      with:
        path: ~/.npm
        key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
        restore-keys: |
          ${{ runner.os }}-node-
    - name: Cache local Maven repository
      id: cache-maven-m2
      uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Build
      id: build-with-maven
      run: mvn clean install -U
