Skip to content

Commit 45bb359

Browse files
committed
Fix OWASP dependency check workflow
1 parent 12a1ea4 commit 45bb359

File tree

3 files changed

+60
-0
lines changed

3 files changed

+60
-0
lines changed

.github/repository-settings.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,5 +98,8 @@ Repository settings in addition to what's documented already at
9898

9999
- `GPG_PASSWORD` - stored in OpenTelemetry-Java 1Password
100100
- `GPG_PRIVATE_KEY` - stored in OpenTelemetry-Java 1Password
101+
- `NVD_API_KEY` - stored in OpenTelemetry-Java 1Password
102+
- Generated at https://nvd.nist.gov/developers/request-an-api-key
103+
- Key is associated with [@trask](https://github.com/trask)'s gmail address
101104
- `SONATYPE_KEY` - owned by [@jack-berg](https://github.com/jack-berg)
102105
- `SONATYPE_USER` - owned by [@jack-berg](https://github.com/jack-berg)

.github/workflows/owasp-dependency-check-daily.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,22 @@ jobs:
2626

2727
- name: Check dependencies
2828
run: ./gradlew dependencyCheckAnalyze
29+
env:
30+
NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
2931

3032
- name: Upload report
3133
if: always()
3234
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
3335
with:
3436
path: javaagent/build/reports
37+
38+
workflow-notification:
39+
permissions:
40+
contents: read
41+
issues: write
42+
needs:
43+
- analyze
44+
if: always()
45+
uses: ./.github/workflows/reusable-workflow-notification.yml
46+
with:
47+
success: ${{ needs.analyze.result == 'success' }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# this is useful because notifications for scheduled workflows are only sent to the user who
2+
# initially created the given workflow
3+
name: Reusable - Workflow notification
4+
5+
on:
6+
workflow_call:
7+
inputs:
8+
success:
9+
type: boolean
10+
required: true
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
workflow-notification:
17+
permissions:
18+
contents: read
19+
issues: write
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
23+
24+
- name: Open issue or add comment if issue already open
25+
env:
26+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27+
run: |
28+
# TODO (trask) search doesn't support exact phrases, so it's possible that this could grab the wrong issue
29+
number=$(gh issue list --search "in:title Workflow failed: $GITHUB_WORKFLOW" --limit 1 --json number -q .[].number)
30+
31+
echo $number
32+
echo ${{ inputs.success }}
33+
34+
if [[ $number ]]; then
35+
if [[ "${{ inputs.success }}" == "true" ]]; then
36+
gh issue close $number
37+
else
38+
gh issue comment $number \
39+
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
40+
fi
41+
elif [[ "${{ inputs.success }}" == "false" ]]; then
42+
gh issue create --title "Workflow failed: $GITHUB_WORKFLOW (#$GITHUB_RUN_NUMBER)" \
43+
--body "See [$GITHUB_WORKFLOW #$GITHUB_RUN_NUMBER](https://github.com/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID)."
44+
fi

0 commit comments

Comments
 (0)