From 5b23722c89754821b515d0653de87d9cf9c51399 Mon Sep 17 00:00:00 2001 From: John Freeman Date: Mon, 1 Aug 2022 21:08:51 +0100 Subject: [PATCH] Extracted maven-periodic-cache-action (#480) For when dependencies change frequently. --- .github/workflows/maven-build.yml | 14 ++------------ .github/workflows/maven-deploy.yml | 16 ++-------------- .github/workflows/release.yml | 16 ++-------------- 3 files changed, 6 insertions(+), 40 deletions(-) diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index d6c83a34..714f3887 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -27,20 +27,10 @@ jobs: with: java-version: 8 distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - name: Cache local Maven repository - uses: actions/cache@v3 + uses: gantsign/maven-periodic-cache-action@v1 with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + additional-path: '!~/.m2/repository/com/github/gantsign/maven' - name: Build with Maven run: .github/scripts/build.sh env: diff --git a/.github/workflows/maven-deploy.yml b/.github/workflows/maven-deploy.yml index 230f9b1d..992da588 100644 --- a/.github/workflows/maven-deploy.yml +++ b/.github/workflows/maven-deploy.yml @@ -22,22 +22,10 @@ jobs: java-version: 8 distribution: 'temurin' gpg-private-key: ${{ secrets.GPG_KEY }} - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - name: Cache local Maven repository - uses: actions/cache@v3 + uses: gantsign/maven-periodic-cache-action@v1 with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }}-deploy - restore-keys: | - ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + additional-path: '!~/.m2/repository/com/github/gantsign/maven' - name: Deploy with Maven run: .github/scripts/deploy.sh env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 794f66e2..c17e3708 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,22 +34,10 @@ jobs: with: java-version: 8 distribution: 'temurin' - # Since code changes to this project are infrequent, and most commits - # change the pom.xml, we cache by date interval rather than file hash. - - name: Calculate cache interval - run: | - leveler="$(wc -c <<< "$GITHUB_REPOSITORY")" - echo "::set-output name=CACHE_INTERVAL::$(date +%Y)-$(($(($leveler + $(date +%-j))) / 30))" - id: cache-interval - name: Cache local Maven repository - uses: actions/cache@v3 + uses: gantsign/maven-periodic-cache-action@v1 with: - path: | - ~/.m2/repository - !~/.m2/repository/com/github/gantsign/maven - key: ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }}-deploy-site - restore-keys: | - ${{ runner.os }}-maven-${{ steps.cache-interval.outputs.CACHE_INTERVAL }} + additional-path: '!~/.m2/repository/com/github/gantsign/maven' - name: Configure Git user run: >- git config --global user.name 'John Freeman' &&