name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Build with Maven
      run: '(test -f pom.xml && mvn -B clean verify --file pom.xml) || echo pom.xml does not exist, skipping step'

name: Java CI

on: [push]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK 11
      uses: actions/setup-java@v1
      with:
        java-version: 11
    - name: Cache maven dependencies
      uses: actions/cache@v1
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-:  
    - name: Build with Maven
      run: '(test -f pom.xml && mvn -B clean verify --file pom.xml) || echo pom.xml does not exist, skipping step'

Introduce cache for build action
Introduce cache for build action