Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/dependency-track.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
on:
pull_request:

name: Dependency Track

jobs:
trivy:
runs-on: ubuntu-latest

container:
image: aquasec/trivy:0.67.2

steps:
- run: trivy --version
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: trivy fs --format cyclonedx --output /tmp/trivy-cyclonedx.json .
- run: apk --no-cache add curl
- run: |
IS_LATEST=false
if [ "${{ github.ref_name }}" = "${{ github.event.repository.default_branch }}" ]; then
IS_LATEST=true
Comment on lines 20 to 23
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The branch detection logic may not function as intended in a pull request context. In pull requests, github.ref_name typically refers to the source branch being merged, not the target branch. To correctly determine if the target branch is the default branch, consider using github.base_ref instead:

if [ "${{ github.base_ref }}" = "${{ github.event.repository.default_branch }}" ]; then
  IS_LATEST=true
fi

This ensures the isLatest flag is properly set when the PR targets the default branch.

Suggested change
- run: |
IS_LATEST=false
if [ "${{ github.ref_name }}" = "${{ github.event.repository.default_branch }}" ]; then
IS_LATEST=true
IS_LATEST=false
if [ "${{ github.base_ref }}" = "${{ github.event.repository.default_branch }}" ]; then
IS_LATEST=true
fi

Spotted by Graphite Agent

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

fi
curl -X "POST" "https://dependency-track.hawk-dinosaur.ts.net/api/v1/bom" \
-H 'Content-Type: multipart/form-data' \
-H "X-Api-Key: ${{ secrets.DEPENDENCY_TRACK_AUTOMATION_API_KEY }}" \
-F "autoCreate=true" \
-F "projectName=${{ github.repository }}" \
-F "projectVersion=${{ github.ref_name }}" \
-F "isLatest=$IS_LATEST" \
-F "bom=@/tmp/trivy-cyclonedx.json"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
Loading