diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 91106d3f4b..c31e187990 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -1,6 +1,10 @@
 name: Java CI
 
-on: [push]
+
+push:
+  branches: [ "master" ]
+pull_request:
+  branches: [ "master" ]
 
 jobs:
   build:
@@ -8,10 +12,12 @@ jobs:
     runs-on: ubuntu-latest
 
     steps:
-    - uses: actions/checkout@v1
-    - name: Set up JDK 1.8
-      uses: actions/setup-java@v1
-      with:
-        java-version: 1.8
-    - name: Build with Maven
-      run: mvn -B package --file pom.xml
+      - uses: actions/checkout@v4
+      - name: Set up JDK 17
+        uses: actions/setup-java@v4
+        with:
+          java-version: '17'
+          distribution: 'temurin'
+          cache: maven
+      - name: Build with Maven
+        run: mvn -B package --file pom.xml