name: CI

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master

jobs:
  build:
    strategy:
      matrix:
        java: [ '8', '11', '13', '14', 16 ]
        os: [ 'ubuntu-latest' ]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK
      uses: actions/setup-java@v2
      with:
        java-version: ${{ matrix.java }}
        distribution: 'zulu'
    - name: print Java version
      run: java -version
    - uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Build
      run: mvn -B clean install --file pom.xml

name: CI

on:
  pull_request:
    branches:
      - master
  push:
    branches:
      - master

jobs:
  build:
    strategy:
      matrix:
        java: [ '8', '11', '17' ]
        os: [ 'ubuntu-latest' ]
    runs-on: ${{ matrix.os }}
    steps:
    - uses: actions/checkout@v2
    - name: Set up JDK
      uses: actions/setup-java@v2
      with:
        java-version: ${{ matrix.java }}
        distribution: 'zulu'
    - name: print Java version
      run: java -version
    - uses: actions/cache@v2
      with:
        path: ~/.m2/repository
        key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
        restore-keys: |
          ${{ runner.os }}-maven-
    - name: Build
      run: mvn -B clean install --file pom.xml

Use only LTS Java versions as of 2021-10
Use only LTS Java versions as of 2021-10

I verified the build locally with Java 17.
