Skip to content

Commit 772b790

Browse files
committed
improve CI caching
1 parent ea227c8 commit 772b790

4 files changed

Lines changed: 65 additions & 54 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: CVE Database Update Scheduled
2+
3+
on:
4+
schedule:
5+
# Every day at 4 AM UTC
6+
- cron: '0 4 * * *'
7+
8+
# Allows you to run this workflow manually from the Actions tab
9+
workflow_dispatch:
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Get Date
16+
id: get-date
17+
run: |
18+
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
19+
shell: bash
20+
21+
- name: Restore Cache - CVE Database
22+
uses: actions/cache@v5
23+
with:
24+
path: |
25+
~/.m2/repository/org/owasp/dependency-check-data
26+
key: ${{ runner.os }}-maven-owasp-cvedb-${{ steps.get-date.outputs.date }}
27+
restore-keys: ${{ runner.os }}-maven-owasp-cvedb
28+
29+
- name: Update CVE Database
30+
env:
31+
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
32+
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
33+
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
34+
run: |
35+
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only

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

Lines changed: 16 additions & 18 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,27 +51,25 @@ 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
55-
uses: actions/cache/restore@v5
56-
with:
57-
path: |
58-
~/.m2/repository/org/owasp/dependency-check-data
59-
key: ${{ runner.os }}-maven-owasp-cvedb
60-
61-
- name: Update CVD Database
62-
env:
63-
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
64-
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
65-
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
54+
- name: Get Date
55+
id: get-date
6656
run: |
67-
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
57+
echo "date=$(/bin/date -u "+%Y-%m-%dT%H:%M:%S")" >> $GITHUB_OUTPUT
58+
shell: bash
6859

69-
- name: Save CVD Database to Cache
70-
uses: actions/cache/save@v5
60+
- name: Restore Cache - CVE Database
61+
uses: actions/cache/restore@v5
7162
with:
7263
path: |
7364
~/.m2/repository/org/owasp/dependency-check-data
74-
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
67+
68+
- name: Fail if cache not restored
69+
if: steps.cache.outputs.cache-hit != 'true'
70+
run: |
71+
echo "Failed to restore OWASP CVE Database - run update manually"
72+
exit 1
7573
7674
- name: Dependency Vulnerability Check with OWASP
7775
env:

.github/workflows/maven-build.yml

Lines changed: 13 additions & 6 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,27 +49,34 @@ 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 - CVE 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

59-
- name: Update CVD Database
66+
- name: Update CVE Database
6067
env:
6168
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
6269
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
6370
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
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 - CVE 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: 1 addition & 30 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,35 +59,6 @@ jobs:
5959
run: |
6060
mvn install -P test --settings maven-ci-settings.xml -B
6161
62-
- name: Restore CVD Database from Cache
63-
uses: actions/cache/restore@v5
64-
with:
65-
path: |
66-
~/.m2/repository/org/owasp/dependency-check-data
67-
key: ${{ runner.os }}-maven-owasp-cvedb
68-
69-
- name: Update CVD Database
70-
env:
71-
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
72-
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
73-
NIST_NVD_API_KEY: ${{ secrets.NIST_NVD_API_KEY }}
74-
run: |
75-
mvn -B -P owasp -DnvdApiDelay=6000 --settings maven-ci-settings.xml org.owasp:dependency-check-maven:update-only
76-
77-
- name: Save CVD Database to Cache
78-
uses: actions/cache/save@v5
79-
with:
80-
path: |
81-
~/.m2/repository/org/owasp/dependency-check-data
82-
key: ${{ runner.os }}-maven-owasp-cvedb
83-
84-
- name: Dependency Vulnerability Check with OWASP
85-
env:
86-
OWASP_OSS_INDEX_USERNAME: ${{ secrets.OWASP_OSS_INDEX_USERNAME }}
87-
OWASP_OSS_INDEX_APIKEY: ${{ secrets.OWASP_OSS_INDEX_APIKEY }}
88-
run: |
89-
mvn org.owasp:dependency-check-maven:aggregate -P owasp --settings maven-ci-settings.xml -B
90-
9162
- name: Build and Deploy with Maven
9263
env:
9364
GPG_EXECUTABLE: gpg

0 commit comments

Comments
 (0)