diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ce65f4a..9b55ac8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,12 +12,22 @@ jobs: fetch-depth: 0 persist-credentials: false + - name: Cache local Maven repository + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: Set up JDK 21 uses: oracle-actions/setup-java@v1 with: website: jdk.java.net release: 21 - - run: ./mvnw clean install -Pall-quality-gates -B + + - name: Run Maven + run: ./mvnw clean install -Pall-quality-gates -B release: runs-on: ubuntu-latest diff --git a/.github/workflows/latest-versions.yml b/.github/workflows/latest-versions.yml index 6f7781a..338be94 100644 --- a/.github/workflows/latest-versions.yml +++ b/.github/workflows/latest-versions.yml @@ -14,4 +14,6 @@ jobs: with: website: jdk.java.net release: 21 - - run: ./mvnw clean versions:update-properties scm:check-local-modification -U -B \ No newline at end of file + + - name: Run Maven + run: ./mvnw clean versions:update-properties scm:check-local-modification -U -B \ No newline at end of file diff --git a/.github/workflows/owasp.yml b/.github/workflows/owasp.yml index d93c9d5..b25d585 100644 --- a/.github/workflows/owasp.yml +++ b/.github/workflows/owasp.yml @@ -9,9 +9,35 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Get Date + id: get-date + run: | + echo "datetime=$(/bin/date -u "+%Y%m%d%H")" >> $GITHUB_OUTPUT + shell: bash + + - name: Restore cached Maven dependencies + uses: actions/cache/restore@v3 + with: + path: ~/.m2/repository + # Using datetime in cache key as OWASP database may change, without the pom changing + key: ${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }}-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }} + ${{ runner.os }}-maven- + - name: Set up JDK 21 uses: oracle-actions/setup-java@v1 with: website: jdk.java.net release: 21 - - run: ./mvnw clean dependency-check:check -DnvdApiKey= -B \ No newline at end of file + + - name: Run Maven + run: ./mvnw clean dependency-check:check -DnvdApiKey=${{ secrets.NVD_API_KEY }} -DnvdApiDelay=6000 -B + + # Want the Maven dependencies to be cached even if the build fails as we want the OWASP database cached, regardless of whether vulnerabilities are found or not + - name: Cache Maven dependencies + uses: actions/cache/save@v3 + if: always() + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ steps.get-date.outputs.datetime }}-${{ hashFiles('**/pom.xml') }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 8e724ff..385fd9b 100644 --- a/pom.xml +++ b/pom.xml @@ -469,9 +469,6 @@ dependency-check-maven ${dependency-check-maven.version} - - ${nvdApiKey} - false