Skip to content

Commit 3852a10

Browse files
committed
OWASP OWASP#714 : Adding sepreate workflow for building the cache
1 parent cacd89d commit 3852a10

File tree

2 files changed

+61
-13
lines changed

2 files changed

+61
-13
lines changed
+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Building JAR cache
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout code
11+
uses: actions/checkout@v4
12+
- name: Set up JDK 21
13+
uses: actions/setup-java@v3
14+
with:
15+
java-version: "21"
16+
distribution: "corretto"
17+
- name: Clean install
18+
run: ./mvnw --no-transfer-progress clean install -DskipTests -Ddependency-check.skip -Dcyclonedx.skip=true -Dexec.skip
19+
- name: Cache JAR file
20+
id: cache-jar
21+
uses: actions/cache@v3
22+
with:
23+
path: ./target/wrongsecrets-1.7.0-SNAPSHOT.jar
24+
key: JarCache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
25+
restore-keys: |
26+
JarCache-${{ runner.os }}-

.github/workflows/dast-zap-test.yml

+35-13
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,43 @@ jobs:
1515
steps:
1616
- name: Checkout code
1717
uses: actions/checkout@v4
18-
- name: Set up JDK 21
19-
uses: actions/setup-java@v3
18+
- uses: actions/checkout@v4
19+
- name: Check the cache
20+
uses: actions/cache/restore@v3
21+
id: cache
2022
with:
21-
java-version: "21"
22-
distribution: "corretto"
23-
- name: Clean install
24-
run: ./mvnw --no-transfer-progress clean install -DskipTests -Ddependency-check.skip -Dcyclonedx.skip=true -Dexec.skip
25-
- name: Cache JAR file
26-
id: cache-jar
27-
uses: actions/cache@v3
28-
with:
29-
path: ./target/wrongsecrets-1.7.0-SNAPSHOT.jar
23+
path: ./target
3024
key: JarCache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
31-
restore-keys: |
32-
JarCache-${{ runner.os }}-
25+
restore-keys: jar-
26+
- name: Check cache hit
27+
id: cache-hit-check
28+
run: echo "cache-hit=${{ steps.cache.outputs.cache-hit }}" >> $GITHUB_ENV
29+
# - name: Set up JDK 21
30+
# uses: actions/setup-java@v3
31+
# with:
32+
# java-version: "21"
33+
# distribution: "corretto"
34+
# - name: Clean install
35+
# run: ./mvnw --no-transfer-progress clean install -DskipTests -Ddependency-check.skip -Dcyclonedx.skip=true -Dexec.skip
36+
# - name: Cache JAR file
37+
# id: cache-jar
38+
# uses: actions/cache@v3
39+
# with:
40+
# path: ./target/wrongsecrets-1.7.0-SNAPSHOT.jar
41+
# key: JarCache-${{ runner.os }}-${{ hashFiles('**/pom.xml') }}
42+
# restore-keys: |
43+
# JarCache-${{ runner.os }}-
44+
- name: Trigger JAR cache build
45+
if: steps.cache.outputs.cache-hit != 'true'
46+
uses: actions/github-script@v6
47+
with:
48+
script: |
49+
await github.rest.actions.createWorkflowDispatch({
50+
owner: context.repo.owner,
51+
repo: context.repo.repo,
52+
workflow_id: 'building-jar-cache.yml', # workflow filename
53+
ref: 'main'
54+
})
3355
- name: Start wrongsecrets
3456
run: nohup ./mvnw spring-boot:run -Dspring-boot.run.profiles=without-vault &
3557
- name: ZAP Scan

0 commit comments

Comments
 (0)