Skip to content

Commit

Permalink
Update caching in the dependency check action
Browse files Browse the repository at this point in the history
The cache strategy of setup-java does not work as I intended: It creates a cache entry once, reloads it in the subsequent runs, but once these runs finish, they don't overwrite the cache.
What does it mean for the dependency check? (n.b. my pom.xml didn't change, which makes the cache key)
- 1st run was the build-and-deploy-to-ossrh action - it created the cache.
- All subsequent runs of the dependency-check action: Take the cache from first run. Oh! There is no database, let's download and build it.

The new strategy:
Every action run creates a new cache entry with the current timestamp as key. restore-keys hopefully picks the latest cache key in the next run.
  • Loading branch information
flange-ipb authored Jan 26, 2022
1 parent 036fd6d commit d4afb20
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion .github/workflows/maven-dependency-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Get Date
id: get-date
run: |
echo "::set-output name=date::$(/bin/date +%s)"
shell: bash
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-dependencies-check-${{ steps.get-date.outputs.date }}
restore-keys: ${{ runner.os }}-maven-dependencies-check-
- name: Set up JDK 8
uses: actions/setup-java@v2
with:
java-version: '8'
distribution: 'adopt'
cache: 'maven'
- id: dependency-check
name: Check maven dependencies
run: |
Expand Down

0 comments on commit d4afb20

Please sign in to comment.