Skip to content

Commit 31c8273

Browse files
committed
Make dependency scan skip when NVD key is absent
1 parent e335940 commit 31c8273

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- main
77
- develop
88
pull_request:
9+
workflow_dispatch:
10+
schedule:
11+
- cron: "0 5 * * 1"
912

1013
jobs:
1114
build-test:
@@ -111,6 +114,7 @@ jobs:
111114
dependency-scan:
112115
name: Dependency Vulnerability Scan
113116
runs-on: ubuntu-latest
117+
timeout-minutes: 25
114118
env:
115119
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
116120

@@ -128,20 +132,21 @@ jobs:
128132
- name: Make Maven Wrapper executable
129133
run: chmod +x mvnw
130134

135+
- name: Skip scan when NVD API key is not configured
136+
if: ${{ env.NVD_API_KEY == '' }}
137+
run: echo "::notice::Skipping OWASP Dependency-Check because NVD_API_KEY is not configured."
138+
131139
- name: Run OWASP Dependency-Check
140+
if: ${{ env.NVD_API_KEY != '' }}
132141
shell: bash
133142
run: |
134-
EXTRA_ARGS=""
135-
if [[ -n "${NVD_API_KEY}" ]]; then
136-
EXTRA_ARGS="-DnvdApiKey=${NVD_API_KEY}"
137-
fi
138143
./mvnw -B -ntp org.owasp:dependency-check-maven:check \
139144
-Dformats=HTML,XML \
140145
-DprettyPrint=true \
141-
${EXTRA_ARGS}
146+
-DnvdApiKey="${NVD_API_KEY}"
142147
143148
- name: Upload dependency-check reports
144-
if: always()
149+
if: ${{ always() && env.NVD_API_KEY != '' }}
145150
uses: actions/upload-artifact@v4
146151
with:
147152
name: dependency-check-report

0 commit comments

Comments
 (0)