Skip to content

Commit c35bfc6

Browse files
committed
Automatically run blackduck scan and commit updated NOTICES file when dependencies change
1 parent e41fb7c commit c35bfc6

File tree

6 files changed

+1945
-1447
lines changed

6 files changed

+1945
-1447
lines changed

.github/actions/blackduck-scan/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ runs:
88
bash <(curl -s https://raw.githubusercontent.com/DACH-NY/security-blackduck/master/synopsys-detect) \
99
ci-build ${GITHUB_REPOSITORY} ${GITHUB_REF_NAME} \
1010
--logging.level.com.synopsys.integration=DEBUG \
11-
--detect.notices.report=false \
11+
--detect.notices.report=true \
1212
--detect.timeout=600 \
1313
--detect.included.detector.types=GO_MOD \
1414
--detect.go.mod.dependency.types.excluded=UNUSED \
1515
--detect.code.location.name=${GITHUB_REPOSITORY}_${GITHUB_JOB} \
1616
--detect.follow.symbolic.links=false
1717
shell: bash -euo pipefail -c "source nix.source && exec bash {0}"
18-
18+

.github/workflows/blackduck.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ defaults:
44
shell: bash -euo pipefail -c "source nix.source && source .envrc.vars && exec bash {0}"
55
on:
66
push:
7-
branches:
8-
- 'blackduck*'
9-
schedule:
10-
- cron: '0 10 * * *' # 5am US Eastern Time (UTC+5)
7+
paths:
8+
- go.mod
9+
- go.sum
1110

1211
concurrency:
1312
group: ${{ github.workflow }}-${{ github.ref }}
@@ -19,11 +18,15 @@ env:
1918

2019
jobs:
2120
scan:
22-
runs-on: dach-ny-dpm
21+
runs-on: digital-asset-dpm
22+
permissions:
23+
contents: write
24+
pull-requests: write
2325
steps:
24-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
26+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
2527
with:
2628
fetch-depth: 0
29+
token: ${{ secrets.AUTO_REBASE_PAT }}
2730
- uses: ./.github/actions/nix
2831
- uses: ./.github/actions/gcloud-login
2932
with:
@@ -33,5 +36,24 @@ jobs:
3336
go build -o target/ ./cmd/...
3437
go test -v ./...
3538
shell: bash -euo pipefail -c "source nix.source && exec bash {0}"
36-
- uses: ./.github/actions/blackduck-scan
37-
39+
- if: ${{ ! contains(github.event.head_commit.message, '[skip notices]') }}
40+
uses: ./.github/actions/blackduck-scan
41+
- if: ${{ ! contains(github.event.head_commit.message, '[skip notices]') }}
42+
name: Rename notices file
43+
run: |
44+
files=( *Black_Duck_Notices_Report.txt )
45+
if [ "${#files[@]}" -eq 1 ]; then
46+
mv -- "${files[0]}" NOTICES
47+
else
48+
echo "Expected exactly one *Black_Duck_Notices_Report.txt file, found ${#files[@]}" >&2
49+
exit 1
50+
fi
51+
shell: bash -euo pipefail -c "source nix.source && exec bash {0}"
52+
- name: Commit and push changes
53+
run: |
54+
git config user.name "github-actions[bot]"
55+
git config user.email "github-actions[bot]@users.noreply.github.com"
56+
git add NOTICES
57+
git commit -m "Update NOTICES after go.mod change" || echo "No changes to commit"
58+
git push
59+
shell: bash -euo pipefail -c "source nix.source && exec bash {0}"

0 commit comments

Comments
 (0)