Skip to content

Commit 99451bc

Browse files
authored
Merge pull request #50 from advanced-security/input-correlator
feat: Add support for running inside a matrix by overriding the default `correlator` identifier
2 parents 691a1cb + fb7126a commit 99451bc

File tree

6 files changed

+28
-5
lines changed

6 files changed

+28
-5
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ jobs:
4040
filePath: "_manifest/spdx_2.2/"
4141
```
4242
43+
Add support for running inside a matrix by overriding the default correlater unique identifier to include the job+matrix values. Consider these sample steps:
44+
45+
```yaml
46+
# Format corrleator as "job(matrixvalue1, matrixvalue2, ... )" or just "job" with a null matrix
47+
- name: Define correlator
48+
id: matrix_parser
49+
run: |
50+
correlator=$(echo '${{ toJSON(matrix) }}' | jq -r 'if . == null then "${{ github.job }}" else "${{ github.job }}(" + ([.[] | tostring] | join(", ")) + ")" end')
51+
echo "correlator=$correlator" >> $GITHUB_OUTPUT
52+
53+
- name: SBOM upload
54+
uses: advanced-security/[email protected]
55+
with:
56+
filePath: "${{ matrix.sbom }}"
57+
correlator: ${{ steps.matrix_parser.outputs.correlator }}
58+
```
59+
4360
## Support
4461
4562
Please create [GitHub Issues][github-issues] if there are bugs or feature requests.

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ inputs:
1313
description: 'The file name pattern for SPDX files to upload'
1414
required: false
1515
default: '*.spdx.json'
16+
correlator:
17+
description: 'The correlator property itself is the primary field used to keep independent submissions distinct.'
18+
required: false
19+
default: ${{ github.job }}
1620
runs:
1721
using: 'node20'
1822
main: 'dist/index.js'

dist/index.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ const VERSION = "0.1.1";
1111
async function run() {
1212
let manifests = lib.getManifestsFromSpdxFiles(lib.searchFiles());
1313

14+
const correlator = core.getInput('correlator');
1415
let snapshot = new toolkit.Snapshot({
1516
name: "spdx-to-dependency-graph-action",
1617
version: VERSION,
1718
url: "https://github.com/advanced-security/spdx-dependency-submission-action",
1819
},
1920
github.context,
2021
{
21-
correlator: `${github.context.job}`,
22+
correlator: correlator,
2223
id: github.context.runId.toString()
2324
});
2425

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)