Skip to content

Commit b19b026

Browse files
pfi79denyeart
authored andcommitted
replace osv-scanner with osv-scanner-action
Signed-off-by: Fedor Partanskiy <[email protected]>
1 parent a27cf91 commit b19b026

File tree

1 file changed

+47
-30
lines changed

1 file changed

+47
-30
lines changed

.github/workflows/vulnerability-scan.yml

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,57 +10,74 @@ on:
1010
- cron: "50 1 * * *"
1111

1212
permissions:
13+
# Required to upload SARIF file to CodeQL. See: https://github.com/github/codeql-action/issues/2117
14+
actions: read
15+
# Require writing security events to upload SARIF file to security tab
16+
security-events: write
17+
# to fetch code (actions/checkout)
1318
contents: read
1419

1520
jobs:
1621
latest:
1722
# Only run the scheduled job in hyperledger/fabric repository, not on personal forks
1823
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'hyperledger/fabric')
19-
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
2024
strategy:
2125
fail-fast: false
2226
matrix:
2327
ref:
2428
- main
2529
- release-2.5
26-
steps:
27-
- name: Checkout ${{ matrix.ref }} branch
28-
uses: actions/checkout@v4
29-
with:
30-
ref: ${{ matrix.ref }}
31-
- name: Set up Go
32-
uses: actions/setup-go@v5
33-
with:
34-
go-version-file: go.mod
35-
- name: Scan
36-
run: go run github.com/google/osv-scanner/v2/cmd/osv-scanner@latest scan --lockfile=go.mod || (( $? > 1 && $? < 127 ))
30+
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@main"
31+
with:
32+
scan-args: |-
33+
--lockfile=./go.mod
34+
--lockfile=./tools/go.mod
35+
matrix-property: ${{ matrix.ref }}-
36+
ref: ${{ matrix.ref }}
3737

38-
release:
38+
get-latest-releases:
3939
# Only run the scheduled job in hyperledger/fabric repository, not on personal forks
4040
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'hyperledger/fabric')
4141
runs-on: ${{ github.repository == 'hyperledger/fabric' && 'fabric-ubuntu-22.04' || 'ubuntu-22.04' }}
4242
strategy:
4343
fail-fast: false
4444
matrix:
4545
ref:
46-
- main
47-
- release-2.5
46+
- branch: main
47+
name: main
48+
- branch: release-2.5
49+
name: release_25
50+
outputs:
51+
output_main: ${{ steps.latest_release.outputs.tag_main }}
52+
output_release-25: ${{ steps.latest_release.outputs.tag_release_25 }}
4853
steps:
49-
- name: Checkout ${{ matrix.ref }} branch
54+
- name: Checkout ${{ matrix.ref.branch }} branch
5055
uses: actions/checkout@v4
5156
with:
52-
ref: ${{ matrix.ref }}
57+
ref: ${{ matrix.ref.branch }}
5358
fetch-depth: 0
54-
- name: Get latest release tag
55-
id: latest-release
56-
run: echo "tag=$(git -c versionsort.suffix=- tag --merged HEAD --sort=-version:refname | head -1)" >> "${GITHUB_OUTPUT}"
57-
- name: Checkout ${{ steps.latest-release.outputs.tag }}
58-
uses: actions/checkout@v4
59-
with:
60-
ref: ${{ steps.latest-release.outputs.tag }}
61-
- name: Set up Go
62-
uses: actions/setup-go@v5
63-
with:
64-
go-version-file: go.mod
65-
- name: Scan
66-
run: go run github.com/google/osv-scanner/v2/cmd/osv-scanner@latest scan --lockfile=go.mod || (( $? > 1 && $? < 127 ))
59+
- name: Get latest release
60+
id: latest_release
61+
run: |
62+
version="${{ matrix.ref.name }}"
63+
echo "tag_${version}=$(git -c versionsort.suffix=- tag --merged HEAD --sort=-version:refname | head -1)" >> "$GITHUB_OUTPUT"
64+
65+
release:
66+
needs:
67+
- get-latest-releases
68+
if: github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository == 'hyperledger/fabric')
69+
strategy:
70+
fail-fast: false
71+
matrix:
72+
ref:
73+
- branch: main
74+
tag: ${{ needs.get-latest-releases.outputs.output_main }}
75+
- branch: release-2.5
76+
tag: ${{ needs.get-latest-releases.outputs.output_release-25 }}
77+
uses: "google/osv-scanner-action/.github/workflows/osv-scanner-reusable.yml@main"
78+
with:
79+
scan-args: |-
80+
--lockfile=./go.mod
81+
--lockfile=./tools/go.mod
82+
matrix-property: ${{ matrix.ref.tag }}-
83+
ref: ${{ matrix.ref.tag }}

0 commit comments

Comments
 (0)