Skip to content

Commit 2e9485f

Browse files
committed
improve CI caching
1 parent ea227c8 commit 2e9485f

3 files changed

Lines changed: 37 additions & 16 deletions

File tree

.github/workflows/maven-build-pr.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ jobs:
1717
# Disabling shallow clone is recommended for improving relevancy of reporting
1818
fetch-depth: 0
1919

20-
- name: Cache maven repository
21-
uses: actions/cache@v5
20+
- name: Restore Cache - Maven Repository
21+
uses: actions/cache/restore@v5
2222
with:
2323
path: |
2424
~/.m2/repository
@@ -51,12 +51,19 @@ jobs:
5151
run: |
5252
mvn install sonar:sonar -P coverage -Dsonar.projectKey=FraunhoferIOSB_FAAAST-Service --settings maven-ci-settings.xml -B
5353
54-
- name: Restore CVD Database from Cache
54+
- name: Get Date
55+
id: get-date
56+
run: |
57+
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
58+
shell: bash
59+
60+
- name: Restore Cache - CVD Database
5561
uses: actions/cache/restore@v5
5662
with:
5763
path: |
5864
~/.m2/repository/org/owasp/dependency-check-data
59-
key: ${{ runner.os }}-maven-owasp-cvedb
65+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
66+
restore-keys: ${{ runner.os }}-maven-owasp-cvedb
6067

6168
- name: Update CVD Database
6269
env:
@@ -66,12 +73,12 @@ jobs:
6673
run: |
6774
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
6875
69-
- name: Save CVD Database to Cache
76+
- name: Save Cache - CVD Database
7077
uses: actions/cache/save@v5
7178
with:
7279
path: |
7380
~/.m2/repository/org/owasp/dependency-check-data
74-
key: ${{ runner.os }}-maven-owasp-cvedb
81+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
7582

7683
- name: Dependency Vulnerability Check with OWASP
7784
env:

.github/workflows/maven-build.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
# Disabling shallow clone is recommended for improving relevancy of reporting
1919
fetch-depth: 0
2020

21-
- name: Cache maven repository
21+
- name: Cache - Maven Repository
2222
uses: actions/cache@v5
2323
with:
2424
path: |
@@ -49,12 +49,19 @@ jobs:
4949
run: |
5050
mvn install sonar:sonar -P coverage -Dsonar.projectKey=FraunhoferIOSB_FAAAST-Service --settings maven-ci-settings.xml -B
5151
52-
- name: Restore CVD Database from Cache
52+
- name: Get Date
53+
id: get-date
54+
run: |
55+
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
56+
shell: bash
57+
58+
- name: Restore Cache - CVD Database
5359
uses: actions/cache/restore@v5
5460
with:
5561
path: |
5662
~/.m2/repository/org/owasp/dependency-check-data
57-
key: ${{ runner.os }}-maven-owasp-cvedb
63+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
64+
restore-keys: ${{ runner.os }}-maven-owasp-cvedb
5865

5966
- name: Update CVD Database
6067
env:
@@ -64,12 +71,12 @@ jobs:
6471
run: |
6572
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
6673
67-
- name: Save CVD Database to Cache
74+
- name: Save Cache - CVD Database
6875
uses: actions/cache/save@v5
6976
with:
7077
path: |
7178
~/.m2/repository/org/owasp/dependency-check-data
72-
key: ${{ runner.os }}-maven-owasp-cvedb
79+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
7380

7481
- name: Dependency Vulnerability Check with OWASP
7582
env:

.github/workflows/maven-deploy.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Checkout Source
2929
uses: actions/checkout@v6
3030

31-
- name: Cache maven repository
31+
- name: Cache - Maven Repository
3232
uses: actions/cache@v5
3333
with:
3434
path: ~/.m2/repository
@@ -59,12 +59,19 @@ jobs:
5959
run: |
6060
mvn install -P test --settings maven-ci-settings.xml -B
6161
62-
- name: Restore CVD Database from Cache
62+
- name: Get Date
63+
id: get-date
64+
run: |
65+
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
66+
shell: bash
67+
68+
- name: Restore Cache - CVD Database
6369
uses: actions/cache/restore@v5
6470
with:
6571
path: |
6672
~/.m2/repository/org/owasp/dependency-check-data
67-
key: ${{ runner.os }}-maven-owasp-cvedb
73+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
74+
restore-keys: ${{ runner.os }}-maven-owasp-cvedb
6875

6976
- name: Update CVD Database
7077
env:
@@ -74,12 +81,12 @@ jobs:
7481
run: |
7582
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
7683
77-
- name: Save CVD Database to Cache
84+
- name: Save Cache - CVD Database
7885
uses: actions/cache/save@v5
7986
with:
8087
path: |
8188
~/.m2/repository/org/owasp/dependency-check-data
82-
key: ${{ runner.os }}-maven-owasp-cvedb
89+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
8390

8491
- name: Dependency Vulnerability Check with OWASP
8592
env:

0 commit comments

Comments
 (0)